stream: fix pipeline with dest in objectMode

pipeline did not support destination with generator
that does not return strings or buffers.

PR-URL: https://github.com/nodejs/node/pull/32414
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Robert Nagy 2020-03-21 22:15:40 +01:00
parent 9e3eddc75d
commit 05f1df5200
2 changed files with 15 additions and 1 deletions

View File

@ -240,7 +240,9 @@ function pipeline(...streams) {
// always returns a stream which can be further
// composed through `.pipe(stream)`.
const pt = new PassThrough();
const pt = new PassThrough({
objectMode: true
});
if (isPromise(ret)) {
ret
.then((val) => {

View File

@ -1065,3 +1065,15 @@ const { promisify } = require('util');
src.push('asd');
dst.destroy();
}
{
pipeline(async function * () {
yield 'asd';
}, async function * (source) {
for await (const chunk of source) {
yield { chunk };
}
}, common.mustCall((err) => {
assert.ifError(err);
}));
}