# js-libp2p-websockets [![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![Coverage Status](https://coveralls.io/repos/github/libp2p/js-libp2p-websockets/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-websockets?branch=master) [![Travis CI](https://travis-ci.org/libp2p/js-libp2p-websockets.svg?branch=master)](https://travis-ci.org/libp2p/js-libp2p-websockets) [![Circle CI](https://circleci.com/gh/libp2p/js-libp2p-websockets.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-websockets) [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-websockets.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websockets) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) ![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square) ![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square) [![Sauce Test Status](https://saucelabs.com/browser-matrix/js-libp2p-websockets.svg)](https://saucelabs.com/u/js-libp2p-websockets) ![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png) ![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png) > JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport interface ## 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 ``` ### This module uses `pull-streams` 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). 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/) #### Converting `pull-streams` to Node.js Streams 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: ```js const pullToStream = require('pull-stream-to-stream') const nodeStreamInstance = pullToStream(pullStreamInstance) // nodeStreamInstance is an instance of a Node.js Stream ``` To learn more about this utility, visit https://pull-stream.github.io/#pull-stream-to-stream. ## API [![](https://raw.githubusercontent.com/diasdavid/interface-transport/master/img/badge.png)](https://github.com/libp2p/interface-transport)