Skip to content

Commit ef7363e

Browse files
committed
stream: allow pass stream class to stream.compose
PR-URL: #50187 Fixes: #50176 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 4032ad5 commit ef7363e

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
@@ -96,6 +96,16 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
9696
assert.match(stringResults[1], /tests 1/);
9797
assert.match(stringResults[1], /pass 1/);
9898
});
99+
100+
it('spec', async () => {
101+
const result = await run({
102+
files: [join(testFixtures, 'default-behavior/test/random.cjs')]
103+
}).compose(spec).toArray();
104+
const stringResults = result.map((bfr) => bfr.toString());
105+
assert.match(stringResults[0], /this should pass/);
106+
assert.match(stringResults[1], /tests 1/);
107+
assert.match(stringResults[1], /pass 1/);
108+
});
99109
});
100110

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

0 commit comments

Comments
 (0)