亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

最后一個輸出流的問題

我的代碼是這樣的,為什么執行出來只輸出一個第一次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);



正在回答

舉報

0/150
提交
取消
進擊Node.js基礎(二)
  • 參與學習       76735    人
  • 解答問題       242    個

本教程帶你攻破 Nodejs,讓 JavaScript流暢運行在服務器端

進入課程

最后一個輸出流的問題

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號