Created
October 15, 2013 03:30
-
-
Save jcrugzz/6986114 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 BufferedList = require('bl'); | |
var source = new BufferedList(), | |
middle = new BufferedList(); | |
// | |
// Buffer a bunch of strings. | |
// | |
for (var i = 0; i < 1000; i++) { | |
source.append('push: ' + i + '\n'); | |
} | |
// | |
// Simulate async behavior... | |
// | |
console.log('waiting ...') | |
setTimeout(function () { | |
// | |
// Ensure the duplex actually emits "end" | |
// | |
middle.on('end', function () { | |
console.log('emitted end'); | |
}); | |
// | |
// Pipe it somewhere. | |
// | |
source.pipe(middle); | |
process.nextTick(function () { | |
middle.pipe(process.stdout); | |
}); | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment