stream: allow returning null from pipeline tail

PR-URL: https://github.com/nodejs/node/pull/42078
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
Robert Nagy authored and GitHub committed 2022-02-25 13:31:20 +00:00
1 parent d5e94fa712
commit 1b47866a1d
2 files changed
+18 -1

No files matched your search

+3 -1
View File
@@ -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();
}
+15
View File
@@ -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);
}));
}