multi-fork
Fork a stream into multiple streams.
installation
npm install multi-fork
example
Partition events by matching object properties with set of ranges.
Code:
var MultiFork = var _ = var u = var streamJohn = var streamAnna = var streamBill = var outputStreams = streamJohn streamAnna streamBill var docs = type: 'Apple' type: 'Banana' type: 'Coco' type: 'Coco'var partitionByKey = 'type'var partitionRanges = 'Apple' 'Banana' 'Coco' var { var index = u return } var multiStream = outputStreamslength classifier: classifier for var index in multiStreamstreams multiStreamstreamsindex
Output:
$ node example.js
{ sendTo: 'John', type: 'Apple' }
{ sendTo: 'Anna', type: 'Banana' }
{ sendTo: 'Bill', type: 'Coco' }
{ sendTo: 'Bill', type: 'Coco' }
license
3-clause BSD. A copy is included with the source.