Fork a stream in multiple directions according to a function.
Overview
fork-stream basically gives you conditional branching for streams. You supply the logic, fork-stream supplies the streaming.
Super Quickstart
Code:
var ForkStream = ; var fork = { return ; }; forka;forkb; fork;fork;fork; fork;
Output:
vowels: hello
no vowels: zxcbzz
vowels: ooooooo
Installation
Available via npm:
$ npm install fork-stream
Or via git:
$ git clone git://github.com/deoxxa/fork-stream.git node_modules/fork-stream
API
constructor
Creates a new fork-stream.
options;
var fork = highWaterMark: 5 { return ; };
- options - regular stream options, and a
classifier
property that fork-stream will use to decide what output stream to send your object down.
Example
Also see example.js.
var ForkStream = ; var fork = { return ; }; forka;forkb; for var i=0;i<20;++i fork;
Output:
b 1
a 6
a 9
a 10
a 7
a 5
b 2
b 4
a 8
b 3
a 5
b 4
a 7
a 8
b 1
a 6
b 2
b 0
a 5
b 1
License
3-clause BSD. A copy is included with the source.
Contact
- GitHub (deoxxa)
- Twitter (@deoxxa)
- Email (deoxxa@fknsrs.biz)