Created
January 6, 2016 22:54
-
-
Save jakubkulhan/d41321c47266a758cdcb to your computer and use it in GitHub Desktop.
js event-stream head-of-line blocking
This file contains hidden or 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 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