stream-n-way
v1.0.0
Published
N-way splitter for streams
Downloads
3
Readme
stream-n-way
N-way splitter for streams.
Install
$ npm install stream-n-way
Usage
new StreamNWay(n[,options])
- Options
<Object>
- streamAtIndex
<Function>
A callback function with an index andoptions
to be invoked for a custom stream. - Any
stream.Readable
options
- streamAtIndex
let stream = require("stream");
let StreamNWay = require("stream-n-way");
let w = new stream.Writable({
objectMode: true,
write(chunk, enc, cb) {
console.log(chunk);
cb();
}
});
// Split a stream to 2 new streams.
let s = new StreamNWay(2, { objectMode: true });
s.children.forEach((c) => c.pipe(w));
// Pushing to `s` will pipe to the two splitter streams.
s.push("Stream me up");
s.push(null);