@libp2p/mplex

JavaScript implementation of https://github.com/libp2p/mplex
Table of contents
Install
$ npm i @libp2p/mplex
Browser <script> tag
Loading this module through a script tag will make it's exports available as Libp2pMplex in the global namespace.
<script src="https://unpkg.com/@libp2p/mplex/dist/index.min.js"></script>

Usage
import { mplex } from '@libp2p/mplex'
import { pipe } from 'it-pipe'
const factory = mplex()
const muxer = factory.createStreamMuxer(components, {
onStream: stream => {
},
onStreamEnd: stream => {
}
})
pipe(conn, muxer, conn)
const stream = muxer.newStream()
pipe([1, 2, 3], stream)
API Docs
License
Licensed under either of
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.