|
10 | 10 | 
|
11 | 11 | 
|
12 | 12 |
|
13 |
| -> Node.js implementation of the TCP module that libp2p uses, which implements |
14 |
| -> the [interface-connection](https://github.com/libp2p/interface-connection) |
15 |
| -> interface for dial/listen. |
| 13 | +> Node.js implementation of the TCP module that libp2p uses, which implements the [interface-connection](https://github.com/libp2p/interface-connection) interface for dial/listen. |
16 | 14 |
|
17 | 15 | ## Description
|
18 | 16 |
|
19 |
| -`libp2p-tcp` in Node.js is a very thin shim that adds support for dialing to a |
20 |
| -`multiaddr`. This small shim will enable libp2p to use other different |
21 |
| -transports. |
| 17 | +`libp2p-tcp` in Node.js is a very thin shim that adds support for dialing to a `multiaddr`. This small shim will enable libp2p to use other different transports. |
22 | 18 |
|
23 | 19 | **Note:** This module uses [pull-streams](https://pull-stream.github.io) for all stream based interfaces.
|
24 | 20 |
|
|
71 | 67 | > npm i libp2p-tcp
|
72 | 68 | ```
|
73 | 69 |
|
| 70 | +## This module uses `pull-streams` |
| 71 | + |
| 72 | +We expose a streaming interface based on `pull-streams`, rather then on the Node.js core streams implementation (aka Node.js streams). `pull-streams` offers us a better mechanism for error handling and flow control guarantees. If you would like to know more about what took us to make this migration, see the discussion at this [issue](https://github.com/ipfs/js-ipfs/issues/362). |
| 73 | + |
| 74 | +You can learn more about pull-streams at: |
| 75 | + |
| 76 | +- [The history of Node.js streams, nodebp April 2014](https://www.youtube.com/watch?v=g5ewQEuXjsQ) |
| 77 | +- [The history of streams, 2016](http://dominictarr.com/post/145135293917/history-of-streams) |
| 78 | +- [pull-streams, the simple streaming primitive](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple) |
| 79 | +- [pull-streams documentation](https://pull-stream.github.io/) |
| 80 | + |
| 81 | +### Converting `pull-streams` to Node.js Streams |
| 82 | + |
| 83 | +If you are a Node.js streams user, you can convert a pull-stream to Node.js Stream using the module `pull-stream-to-stream`, giving you an instance of a Node.js stream that is linked to the pull-stream. Example: |
| 84 | + |
| 85 | +``` |
| 86 | +const pullToStream = require('pull-stream-to-stream') |
| 87 | +
|
| 88 | +const nodeStreamInstance = pullToStream(pullStreamInstance) |
| 89 | +// nodeStreamInstance is an instance of a Node.js Stream |
| 90 | +``` |
| 91 | + |
| 92 | +To learn more about his utility, visit https://pull-stream.github.io/#pull-stream-to-stream |
| 93 | + |
74 | 94 | ## API
|
75 | 95 |
|
76 | 96 | [](https://github.com/diasdavid/interface-transport)
|
|
0 commit comments