Filter object streams
The cop Node.js module is a Transform stream (in object mode) which is configurable to emit specific properties of objects written to it. Furthermore, if provided with a filter function,
cop can be used to massage data.
var cop = require'cop'Readable = require'stream'Readablevar objs =thing: 'My hovercraft 'thing: 'is full 'thing: 'of eels.\n'var reader = objectMode:truelength = objslengthi = 0readerpushi < length ? objsi++ : nullreaderpipecop'thing'pipeprocessstdout
var cop = require'cop'fstream = require'fstream'reader = fstreamReader path:processcwdreaderpipecopfilterpipeprocessstdoutreturn obj ? obj'path' + '\n' : undefined
keyName of the property of which to emit the value
Provided a key,
cop will emit the matching property of an object written to it. If the object has no matching property nothing is emitted.
filterFilter function which is applied to each object written to the stream
Alternatively a filter function can be provided, which is executed before data is emitted, hence, provides an opportunity to massage the data.