Rasi
answered Nov 30 '-1 00:00
filterstream.js
var Stream = require('stream');
var ts = new Stream;
ts.readable =true;
ts.writable = true;
ts.write = function (buff){
ts.emit('data',buff.toString().toUpperCase());
}
ts.end=function(buf){
if(arguments.length){
ts.write(buff);
}
ts.emit('end');
}
process.stdin.pipe(ts).pipe(process.stdout);
above is filter streaming example
var Stream = require('stream'); will load stream module
we making it readable and writable stream
ts.readable =true;
ts.writable = true;