Created
September 5, 2013 20:05
-
-
Save isaacs/6455434 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 stream = require('stream'); | |
var assert = require('assert'); | |
var PassThrough = stream.PassThrough; | |
var src = new PassThrough({ objectMode: true }); | |
var tx = new PassThrough({ objectMode: true }); | |
var dest = new PassThrough({ objectMode: true }); | |
dest.on('data', function(x) { | |
console.log('%s %j', typeof x, x); | |
}); | |
src.pipe(tx).pipe(dest); | |
var i = -1; | |
var int = setInterval(function() { | |
console.error('interval', i); | |
if (i > 10) { | |
src.end(); | |
clearInterval(int); | |
} else { | |
src.write(i++); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment