Skip to content

Commit ffdc357

Browse files
himself65targos
authored andcommitted
stream: allow pass stream class to stream.compose
PR-URL: #50187 Fixes: #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

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/internal/streams/duplexify.js

+5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ module.exports = function duplexify(body, name) {
8585
if (typeof body === '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+
return value;
91+
}
92+
8893
if (isIterable(value)) {
8994
return from(Duplexify, value, {
9095
// TODO (ronag): highWaterMark?

test/parallel/test-runner-run.mjs

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

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

0 commit comments

Comments
 (0)