Skip to content

Instantly share code, notes, and snippets.

@jakubkulhan
Created January 6, 2016 22:54
Show Gist options
  • Select an option

  • Save jakubkulhan/d41321c47266a758cdcb to your computer and use it in GitHub Desktop.

Select an option

Save jakubkulhan/d41321c47266a758cdcb to your computer and use it in GitHub Desktop.
js event-stream head-of-line blocking
var EventStream = require('event-stream'),
i = 0;
process.stdin
.pipe(EventStream.map(function (req, cb) {
if (i++ % 2 === 0) {
setTimeout(function () {
cb(null, "" + req);
}, 5000);
} else {
cb(null, "" + req);
}
}))
.pipe(process.stdout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment