Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 041d2ea

Browse files
committed
feat(readme): add pull-streams documentation
1 parent 0f4619a commit 041d2ea

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

README.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@
1010
![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png)
1111
![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)
1212

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.
1614
1715
## Description
1816

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.
2218

2319
**Note:** This module uses [pull-streams](https://pull-stream.github.io) for all stream based interfaces.
2420

@@ -71,6 +67,30 @@ hello
7167
> npm i libp2p-tcp
7268
```
7369

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+
7494
## API
7595

7696
[![](https://raw.githubusercontent.com/diasdavid/interface-transport/master/img/badge.png)](https://github.com/diasdavid/interface-transport)

0 commit comments

Comments
 (0)