我不能连续两个流在 node.js 中工作。请参阅以下代码:
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);
如何让两个流连续工作?