package
Combine multiple duplex streams into just one
npm install combine-streamGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 11 packages.
900.8 kB
Includes dependencies.

Combine multiple duplex streams into just one.
combine-stream lets you treat a few streams as just one, in a parallel fashion. When you combine a bunch of streams, you write to it as if it was one, and read from it as if it was one, but you are simultaneously writing to all the streams and getting the output from all the streams.
Error events are also aggregated from all the streams and forwarded up through the combining stream for you to listen to in one place.
Code:
var stream = require("stream");
var CombineStream = require("combine-stream");
var streamA = new stream.PassThrough({objectMode: true}),
streamB = new stream.PassThrough({objectMode: true}),
streamC = new stream.PassThrough({objectMode: true});
var combine = new CombineStream([streamA, streamB, streamC]);
combine.on("data", console.log);
combine.write("hello");
combine.end();Output:
hello
hello
helloAvailable via npm:
$ npm install combine-stream
Or via git:
$ git clone git://github.com/deoxxa/combine-stream.git node_modules/combine-stream
NOTE:
Currently this is relying on my fork of readable-stream. Hopefully my patch gets merged and I can remove the hardcoded github dependency.
constructor
Creates a new combine-stream.
new CombineStream(options);var combine = new CombineStream({
logSize: 100,
recordDuplicates: true,
comparator: functon compare(a, b) {
return a === b;
},
});Arguments
TransformStream
options, the parameters described below. If this argument is an array, it will
be wrapped in {streams: ...}.options
Also see example.js.
var stream = require("stream");
var CombineStream = require("combine-stream");
var delayed = function delayed(n) {
var s = new stream.Transform({objectMode: true});
s._transform = function _transform(input, encoding, done) {
var self = this;
return setTimeout(function() {
self.push(input + " " + n);
return done();
}, n);
Output:
hello 1 100
hello 1 500
hello 2 100
hello 2 500
hello 3 100
hello 3 500
ending! 100
ending! 500
everything finished3-clause BSD. A copy is included with the source.
hemanth
hemanth.hm@gmail.com