if-stream 
Conditionally return a stream
Install
$ npm install --save if-stream
Usage
var csvParser = require('csv-parser');
var ifStream = require('if-stream');
function isCsv(data) {
return data.toString().indexOf(',') !== -1;
}
var stream = ifStream(isCsv, csvParser);
stream.on('data', function (data) {
console.log(data);
});
stream.end('foo,unicorn\nbar,cat\n');
API
ifStream(condition, stream, [optionalStream], options)
condition
Required
Type: function, string, boolean or regex
Condition to match the stream buffer against.
stream
Required
Type: stream
The stream to be returned if the condition is met.
optionalStream
Type: stream
An optional stream to be returned if the condition isn't met. By default a
transform stream is returned.
options
Type: object
Options to pass to peek-stream.
License
MIT © Kevin Martensson