Created
April 16, 2016 14:27
-
-
Save homam/805742d255c84d0d731fecd94a93df4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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