stream: pipeline with end option · nodejs/node@e110c96 · GitHub
Skip to content

Commit e110c96

Browse files
ronagdanielleadams
authored andcommitted
stream: pipeline with end option
Currently pipeline cannot fully replace pipe due to the missing end option. This PR adds the end option to the promisified pipeline method. PR-URL: #40886 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e092fde commit e110c96

3 files changed

Lines changed: 50 additions & 17 deletions

File tree

lib/internal/streams/pipeline.js

Lines changed: 25 additions & 15 deletions

lib/stream/promises.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ const eos = require('internal/streams/end-of-stream');
1616
function pipeline(...streams) {
1717
return new Promise((resolve, reject) => {
1818
let signal;
19+
let end;
1920
const lastArg = streams[streams.length - 1];
2021
if (lastArg && typeof lastArg === 'object' &&
2122
!isNodeStream(lastArg) && !isIterable(lastArg)) {
2223
const options = ArrayPrototypePop(streams);
2324
signal = options.signal;
25+
end = options.end;
2426
}
2527

2628
pl(streams, (err, value) => {
@@ -29,7 +31,7 @@ function pipeline(...streams) {
2931
} else {
3032
resolve(value);
3133
}
32-
}, { signal });
34+
}, { signal, end });
3335
});
3436
}
3537

test/parallel/test-stream-pipeline.js

Lines changed: 22 additions & 1 deletion

0 commit comments

Comments
 (0)