Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
stream: allow returning null from pipeline tail
  • Loading branch information
ronag committed Feb 22, 2022
commit bdf950d5cc55be893181f28b842b91d6fe0a3309
4 changes: 3 additions & 1 deletion lib/internal/streams/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ function pipelineImpl(streams, callback, opts) {
then.call(ret,
(val) => {
value = val;
pt.write(val);
if (val != null) {
pt.write(val);
}
if (end) {
pt.end();
}
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1511,3 +1511,18 @@ const tsp = require('timers/promises');
assert.strictEqual(s.destroyed, true);
}));
}

{
const s = new PassThrough({ objectMode: true });
pipeline(async function*() {
await Promise.resolve();
yield 'hello';
yield 'world';
yield 'world';
}, s, async function(source) {
return null;
}, common.mustCall((err, val) => {
assert.strictEqual(err, undefined);
assert.strictEqual(val, null);
}));
}