私は Node.js ストリームで練習していますが、次のコードに問題があります。
'use strict'
let stream = require('stream');
let logger = new stream.Transform({
transform: function (chunk, encoding, next) {
console.log(`Chunk: ${chunk}`);
this.push(chunk);
next();
}
})
let liner = new stream.Transform({
transform: function (chunk, encoding, next) {
chunk.toString().split('\r\n').forEach(e=>this.push(e));
next();
}
})
process.stdin.pipe(logger).pipe(liner).pipe(logger);
ロガーへの 2 つの呼び出しは、ロガー ストリームの異なるインスタンスであると予想していましたが、それらは同じように見え、無限ループに陥ります。
どうもありがとうございました。