and-stream
Node.js Stream to filter multiple-streams of incoming objects, and only return objects that are present in ALL streams.
Installation
Install via npm:
$ npm install and-stream
Examples
Only print out objects that are present in two input object streams
var andStream = ;// No key passed into the factory method, so just uses JSON.stringify for uniquenessvar and = ;and;// emits objects;// emits objects;// Only objects that are identical and emitted by both streams will be printed
The and-stream
constructor takes an optional argument which is used to
determine the unique key to identify an object by. If not used, it will
default to using JSON.stringify
to uniquely identify each object, so only
if the exact same object is present on all streams will the objected be
emmitted by the and-stream
.
name
property on the object as the object key
Use the var andStream = ;// Use the 'name' field as the key for anding object streamsvar and = ;and;// emits objects;// emits objects;// Only objects that have the same .name field on both streams will be printed
Use a custom function on the objects to determine the key
var andStream = ;// Use the 'name' field as the key for anding object streamsvar and =;and;// emits objects;// emits objects;// Only objects that have the same base64 of the .name field on both streams will be printed