-
-
Save rvagg/8796067 to your computer and use it in GitHub Desktop.
This file contains 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 Readable = require('stream').Readable; | |
var Writable = require('stream').Writable; | |
var readable = Readable(); | |
readable._read = function(){ | |
readable._t = setTimeout(function(){ | |
readable.push(''+Date.now()); | |
}, 100); | |
} | |
readable.on('end', function(){ console.log('end') }) | |
readable.on('finish', function(){ console.log('finish') }) | |
readable.on('close', function(){ console.log('close') }) | |
var writable = Writable(); | |
writable._write = function(chunk, _, done){ | |
console.log(chunk.toString()); | |
done(); | |
}; | |
readable.pipe(writable) | |
writable.on('finish', function () { | |
clearTimeout(readable._t) | |
readable.push(null) | |
}) | |
setTimeout(function(){ | |
writable.end(); | |
}, 1000); |
This file contains 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
1391476923961 | |
1391476924067 | |
1391476924168 | |
1391476924269 | |
1391476924371 | |
1391476924472 | |
1391476924573 | |
1391476924673 | |
1391476924774 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment