{"name":"stream-channels","version":"1.4.0","description":"Simple one-way stream multiplexer with very few features","main":"index.js","dependencies":{"duplexify":"^3.5.0","inherits":"^2.0.3","length-prefixed-stream":"^1.5.0","readable-stream":"^2.1.5","varint":"^5.0.0"},"devDependencies":{"dev-zero-stream":"^1.1.0","nanobench":"^1.0.3","standard":"^8.4.0","tape":"^4.6.2"},"scripts":{"test":"standard && tape test.js","bench":"nanobench benchmark.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/stream-channels.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/stream-channels/issues"},"homepage":"https://github.com/mafintosh/stream-channels","gitHead":"5cf8ed32e76b3fa4511e869096e64398453847c5","_id":"stream-channels@1.4.0","_shasum":"f09ae92e95ce3c908fe7431b45ff6e98fc33e975","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"f09ae92e95ce3c908fe7431b45ff6e98fc33e975","tarball":"http://registry-npm.ywwl.com/stream-channels/download/stream-channels-1.4.0.tgz","integrity":"sha512-sl0tf6TJTVHbg52cOqnj+uSQuoyiC4J3sqo/v/t47GQv7+ADURQVORWyosECWuFMtzf3GINLyWYEIbqrkJYZGw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA4hNe6yP0vaAsawmr+aszqOZ3WEZZy8DubRElZz13y4AiEAmcFb4UZf9cc4ryvvesm6+rhBVmOcmzARnIlsotSNRLI="}],"size":4907,"noattachment":false,"key":"/stream-channels/-/stream-channels-1.4.0.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/stream-channels-1.4.0.tgz_1481631068650_0.48180827545002103"},"directories":{},"readme":"# stream-channels\n\nSimple one-way stream multiplexer with very few features.\nFor two-way (full duplex) multiplexing see the [multiplex](https://github.com/maxogden/multiplex) module.\n\n```\nnpm install stream-channels\n```\n\n[![build status](http://img.shields.io/travis/mafintosh/stream-channels.svg?style=flat)](http://travis-ci.org/mafintosh/stream-channels)\n\n## Usage\n\n``` js\nvar channels = require('stream-channels')\nvar stream = channels()\n\nstream.on('channel', function (channel) {\n  console.log('new channel')\n  channel.on('data', console.log)\n  channel.on('end', function () {\n    console.log('(no more data)')\n  })\n})\n\nvar ch1 = stream.createChannel()\nvar ch2 = stream.createChannel()\n\nch1.write('hello')\nch2.write('world')\n\nch1.end()\nch2.end()\n\nstream.pipe(stream)\n```\n\n## API\n\n#### `var stream = channels([options], [onchannel])`\n\nCreate a new instance. Options include:\n\n``` js\n{\n  limit: maxChannelsAllowedOpen // defaults to 1024\n}\n```\n\n#### `var writeableStream = stream.createChannel()`\n\nCreate a new channel.\n\n#### `stream.on('channel', readableStream)`\n\nEmitted when a remote creates a new channel. Will emit the data the remote writes to it.\n\n#### `stream.setTimeout(ms, [ontimeout])`\n\nEmit a timeout when if the stream is inactive for ~ms milliseconds.\nWill start a heartbeat as well.\n\n## Wire Protocol\n\nThe wire protocol is as follows.\n\n```\n------------------------------\n| length | channel-id | data |\n------------------------------\n```\n\n* Length is a [varint](https://github.com/chrisdickinson/varint) containing the binary length of channel-id and data.\n* Channel id is a [varint](https://github.com/chrisdickinson/varint) representing the current channel.\n* Data is the buffer you wrote to a channel\n\nChannels are lazily opened., The first time you receive data on a channel id, that channel is opened.\nReceiving an empty data buffer indicates that the channel is closed.\n\nMessages received with length 0 should be ignored and can be used as a keep alive signal.\n\n## Back pressure\n\nBack pressure will trigger on all channels when the *slowest* channel starts to back pressure.\n\n## License\n\nMIT\n","publish_time":1481631069284,"_cnpm_publish_time":1481631069284,"dist-tags":{"latest":"1.4.1"}}