Skip to content

Instantly share code, notes, and snippets.

@homam
Created April 16, 2016 14:27
Show Gist options
  • Save homam/805742d255c84d0d731fecd94a93df4f to your computer and use it in GitHub Desktop.
Save homam/805742d255c84d0d731fecd94a93df4f to your computer and use it in GitHub Desktop.
var stream = require("stream");
var rstream = (function() {
var i = 0;
var rstream = new stream.Readable();
rstream._read = function(){
return this.push(++i > 2 ? "" : ["hello","world"][i-1]);
};
return rstream
})();
var wstream = new stream.Writable();
wstream._write = function(chunk, enc, next){
console.log("w", chunk.toString());
return next();
};
rstream.pipe(wstream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment