Skip to content

Instantly share code, notes, and snippets.

@jcrugzz
Created October 15, 2013 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcrugzz/6986114 to your computer and use it in GitHub Desktop.
Save jcrugzz/6986114 to your computer and use it in GitHub Desktop.
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