Skip to content

Commit ffdc357

Browse files
himself65targos
authored andcommitted
stream: allow pass stream class to stream.compose
PR-URL: #50187Fixes: #50176 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 85de4b8 commit ffdc357

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎lib/internal/streams/duplexify.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ module.exports = function duplexify(body, name) {
8585
if(typeofbody==='function'){
8686
const{ value, write, final, destroy }=fromAsyncGen(body);
8787

88+
// Body might be a constructor function instead of an async generator function.
89+
if(isDuplexNodeStream(value)){
90+
returnvalue;
91+
}
92+
8893
if(isIterable(value)){
8994
returnfrom(Duplexify,value,{
9095
// TODO (ronag): highWaterMark?

‎test/parallel/test-runner-run.mjs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
104104
assert.match(stringResults[1],/tests1/);
105105
assert.match(stringResults[1],/pass1/);
106106
});
107+
108+
it('spec',async()=>{
109+
constresult=awaitrun({
110+
files: [join(testFixtures,'default-behavior/test/random.cjs')]
111+
}).compose(spec).toArray();
112+
conststringResults=result.map((bfr)=>bfr.toString());
113+
assert.match(stringResults[0],/thisshouldpass/);
114+
assert.match(stringResults[1],/tests1/);
115+
assert.match(stringResults[1],/pass1/);
116+
});
107117
});
108118

109119
it('should be piped with tap',async()=>{

0 commit comments

Comments
 (0)