2016-08-11 11:59:11 +02:00
# js-libp2p-websockets
2016-02-26 11:01:52 +00:00
[](http://ipn.io)
2016-08-11 11:59:11 +02:00
[](http://ipfs.io/)
2016-03-14 20:25:00 +00:00
[](http://webchat.freenode.net/?channels=%23ipfs)
2016-08-11 11:59:11 +02:00
[](https://coveralls.io/github/libp2p/js-libp2p-websockets?branch=master)
[](https://travis-ci.org/libp2p/js-libp2p-websockets)
[](https://circleci.com/gh/libp2p/js-libp2p-websockets)
[](https://david-dm.org/libp2p/js-libp2p-websockets) [](https://github.com/feross/standard)
2016-11-03 09:53:50 +01:00


[](https://saucelabs.com/u/js-libp2p-websockets)
2016-02-26 11:01:52 +00:00
2016-06-19 06:35:31 +01:00


2016-11-03 09:53:50 +01:00
2016-06-19 06:35:31 +01:00
> JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport interface
2016-09-05 19:07:00 -04:00
## Description
`libp2p-websockets` is the WebSockets implementation compatible with libp2p.
**Note:** This module uses [pull-streams ](https://pull-stream.github.io ) for all stream based interfaces.
## Example
```
TODO
```
## Installation
### npm
```sh
> npm i libp2p-websockets
```
2016-09-06 09:37:27 -04:00
### This module uses `pull-streams`
2016-09-05 19:07:00 -04:00
2016-09-06 09:37:27 -04:00
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 why we did this, see the discussion at this [issue ](https://github.com/ipfs/js-ipfs/issues/362 ).
2016-09-05 19:07:00 -04:00
You can learn more about pull-streams at:
- [The history of Node.js streams, nodebp April 2014 ](https://www.youtube.com/watch?v=g5ewQEuXjsQ )
- [The history of streams, 2016 ](http://dominictarr.com/post/145135293917/history-of-streams )
- [pull-streams, the simple streaming primitive ](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple )
- [pull-streams documentation ](https://pull-stream.github.io/ )
2016-09-06 09:37:27 -04:00
#### Converting `pull-streams` to Node.js Streams
2016-09-05 19:07:00 -04:00
2016-09-30 14:48:06 -04:00
If you are a Node.js streams user, you can convert a pull-stream to a Node.js stream using the module [`pull-stream-to-stream` ](https://github.com/pull-stream/pull-stream-to-stream ), giving you an instance of a Node.js stream that is linked to the pull-stream. For example:
2016-09-05 19:07:00 -04:00
2016-09-06 09:37:27 -04:00
```js
2016-09-05 19:07:00 -04:00
const pullToStream = require('pull-stream-to-stream')
const nodeStreamInstance = pullToStream(pullStreamInstance)
// nodeStreamInstance is an instance of a Node.js Stream
```
2016-09-06 09:37:27 -04:00
To learn more about this utility, visit https://pull-stream.github.io/#pull -stream-to-stream.
2016-09-05 19:07:00 -04:00
## API
2016-09-30 14:48:06 -04:00
[](https://github.com/libp2p/interface-transport)