1
爲什麼下面的代碼(保存爲dummy.js
)會引發錯誤?什麼是修復?NodeJS:嘗試推動可讀性拋出「Error:not implemented」
var Stream = require('stream');
var src = new Stream.Readable();
var dest = new Stream();
dest.writable = true;
dest.write = function(data) { console.log("dest:",data); };
["1","2","3"].forEach(function(f) { console.log(f); src.push(f); });
src.pipe(dest);
執行:
> node dummy.js
1
2
3
events.js:72
throw er; // Unhandled 'error' event
^
Error: not implemented
at Readable._read (_stream_readable.js:446:22)
at Readable.read (_stream_readable.js:320:10)
at Readable.on (_stream_readable.js:701:14)
at Readable.pipe (_stream_readable.js:556:10)
at Object.<anonymous> (/home/jay/dummy.js:16:5)
at (etc.)