最后一个输出流的问题
我的代码是这样的,为什么执行出来只输出一个第一次push进去的内容啊
var stream = require('stream');
var util = require('util');
function ReadStream () {
stream.Readable.call(this);
}
util.inherits(ReadStream, stream.Readable);
ReadStream.prototype._read = function () {
this.push(' I');
this.push(' love');
this.push(' imooc,');
this.push(null);
};
function WriteStream () {
stream.Writable.call(this);
this._cached = new Buffer.from('');
}
util.inherits(WriteStream, stream.Writable);
WriteStream.prototype._write = function (chunk) {
console.log(chunk.toString());
};
function TransformStream () {
stream.Transform.call(this);
}
util.inherits(TransformStream, stream.Transform);
TransformStream.prototype._transform = function(chunk){
this.push(chunk);
};
TransformStream.prototype._flush = function(cb){
this.push('12345');
cb && cb();
};
var rs = new ReadStream();
var ws = new WriteStream();
var ts = new TransformStream();
rs.pipe(ts).pipe(ws);