|
10 | 10 |
|
11 | 11 | 
|
12 | 12 | 
|
13 |
| - |
14 | 13 | > JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport interface
|
| 14 | +
|
| 15 | +## Description |
| 16 | + |
| 17 | +`libp2p-websockets` is the WebSockets implementation compatible with libp2p. |
| 18 | + |
| 19 | +**Note:** This module uses [pull-streams](https://pull-stream.github.io) for all stream based interfaces. |
| 20 | + |
| 21 | +## Example |
| 22 | + |
| 23 | +``` |
| 24 | +TODO |
| 25 | +``` |
| 26 | + |
| 27 | +## Installation |
| 28 | + |
| 29 | +### npm |
| 30 | + |
| 31 | +```sh |
| 32 | +> npm i libp2p-websockets |
| 33 | +``` |
| 34 | + |
| 35 | +## This module uses `pull-streams` |
| 36 | + |
| 37 | +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). |
| 38 | + |
| 39 | +You can learn more about pull-streams at: |
| 40 | + |
| 41 | +- [The history of Node.js streams, nodebp April 2014](https://www.youtube.com/watch?v=g5ewQEuXjsQ) |
| 42 | +- [The history of streams, 2016](http://dominictarr.com/post/145135293917/history-of-streams) |
| 43 | +- [pull-streams, the simple streaming primitive](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple) |
| 44 | +- [pull-streams documentation](https://pull-stream.github.io/) |
| 45 | + |
| 46 | +### Converting `pull-streams` to Node.js Streams |
| 47 | + |
| 48 | +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: |
| 49 | + |
| 50 | +``` |
| 51 | +const pullToStream = require('pull-stream-to-stream') |
| 52 | +
|
| 53 | +const nodeStreamInstance = pullToStream(pullStreamInstance) |
| 54 | +// nodeStreamInstance is an instance of a Node.js Stream |
| 55 | +``` |
| 56 | + |
| 57 | +To learn more about his utility, visit https://pull-stream.github.io/#pull-stream-to-stream |
| 58 | + |
| 59 | +## API |
| 60 | + |
| 61 | +[](https://github.com/diasdavid/interface-transport) |
0 commit comments