The following code is a copy of an example in README plusfinish event. I assumed the parallel transform emits finish after all data consumption but is didn't.
varstream=transform(10,function(data,callback){setTimeout(function(){callback(null,data);},Math.random()*1000);});for(vari=0;i<10;i++){stream.write(''+i);}stream.end();stream.on('finish',function(){console.log('stream has finished');});stream.on('end',function(){console.log('stream has ended');});output
0
stream has finished
1
2
3
4
5
6
7
8
9
stream has ended
This is not pleasant especially when we use libs such as pump that calls a callback function depending on finish event.
It seems that it emits finishafter all writable data is buffered instead of consumed.
This problem occurs also in parallel-stream module.
Also, when we do readable.pipe(parallelTransform).pipe(writable), the writable emits finish earlier than expected.
The following code is a copy of an example in README plus
finishevent. I assumed the parallel transform emitsfinishafter all data consumption but is didn't.output
This is not pleasant especially when we use libs such as
pumpthat calls a callback function depending onfinishevent.It seems that it emits
finishafter all writable data is buffered instead of consumed.This problem occurs also in
parallel-streammodule.Also, when we do
readable.pipe(parallelTransform).pipe(writable), the writable emitsfinishearlier than expected.