{"name":"stream-channels","version":"0.0.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":"^4.0.1"},"devDependencies":{"standard":"^8.4.0","tape":"^4.6.2"},"scripts":{"test":"standard && tape test.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":"f89051cc0961bb0cbc9b9c63eeca3a66dc3b7fde","_id":"stream-channels@0.0.0","_shasum":"8f9fad29442daee8f091e0af947e2ac2e598c57a","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.6.1","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"8f9fad29442daee8f091e0af947e2ac2e598c57a","tarball":"http://registry-npm.ywwl.com/stream-channels/download/stream-channels-0.0.0.tgz","integrity":"sha512-RbWBWwpKQg2V+n/j6MWCinmXnHuFHi9zTbpQRDSSQpSfb9DhgFrCu0M6goPL6IIHm4lmNMrGGxdzww9PqXM+Zw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD9BmFV1NNjSkqKS56GT6qjkPsF/m+IQ84d+aKmZ7wFbQIgV1fa9H8BOcBqCYIUSkSS8ID46BYeggex++WxxKBz/Sc="}],"size":3901,"noattachment":false,"key":"/stream-channels/-/stream-channels-0.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/stream-channels-0.0.0.tgz_1477320175704_0.7160090175457299"},"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":1477320177182,"_cnpm_publish_time":1477320177182,"dist-tags":{"latest":"1.4.1"}}