Last active
December 14, 2015 16:19
-
-
Save jwulf/d414edfb4ff7e4a96857 to your computer and use it in GitHub Desktop.
Minimal Streams reproducer. Piping stream1 -> stream2 -> process.stdout works.
Piping stream1 -> stream2 -> stream3 -> process.stdout does not work. Why?
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 stream1 = new Stream; | |
stream1.readable = true; | |
var stream2 = new Stream; | |
stream2.readable = stream2.writable = true; | |
var stream3 = new Stream; | |
stream3.readable = stream3.writeable = true; | |
var i = 0; | |
stream2.write = function(data){this.emit('data', data)}; | |
stream3.write = function(data){this.emit('data', data)}; | |
setInterval((function() { | |
stream1.emit('data', String(i++)); | |
}), 100); | |
//works: | |
stream1.pipe(stream2).pipe(process.stdout); | |
//does not work - why??? | |
//stream1.pipe(stream2).pipe(stream3).pipe(process.stdout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment