In the example below it writes "foo" to process.stdout once. Why doesn't it write "foo" 10 times?
const { Transform } = require('stream');
class Stream extends Transform {
constructor(){
super({autoDestroy : false, emitClose :false});
}
_transform(chunk, encoding, callback){
this.push(chunk);
}
}
let stream = new Stream();
stream.pipe(process.stdout, {end:false});
for (let i = 0; i < 10; i++) {
stream.write('foo');
}
The reason it doesn't print "foo" 10 times is because I didn't carefully read the documentation:
fixes it.