$ npm install --save filter-stream2
var filterStream = require('filter-stream2');
createAReadStream().pipe(filterStream(function (chunk, enc, done) {
// Some test on the chunk
if (chunk.indexOf('some string i am looking for ...?') !== -1) {
// Pass this chunk downstream
return done(true);
}
// Otherwise dont pass this chunk down
done(false);
}));
// Other methods
filterStream.sync(); // Just a sync version where you return true/false
filterStream.obj(); // Object stream version
filterStream.objSync(); // Sync version of object stream