-
-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
The following code is a copy of an example in README plus finish event. I assumed the parallel transform emits finish after all data consumption but is didn't.
var stream = transform(10, function (data, callback) {
setTimeout(function () {
callback(null, data);
}, Math.random() * 1000);
});
for (var i = 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 finish after 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.
Metadata
Metadata
Assignees
Labels
No labels