GeezerVison is showing github.com — stream: allow pass stream class to `stream.compose` · nodejs/node@789372a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/streams/duplexify.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -85,6 +85,11 @@ module.exports = function duplexify(body, name) { |
85 | 85 | if (typeof body === 'function') { |
86 | 86 | const { value, write, final, destroy } = fromAsyncGen(body); |
87 | 87 |
|
| 88 | + // Body might be a constructor function instead of an async generator function. |
| 89 | + if (isDuplexNodeStream(value)) { |
| 90 | + return value; |
| 91 | + } |
| 92 | + |
88 | 93 | if (isIterable(value)) { |
89 | 94 | return from(Duplexify, value, { |
90 | 95 | // TODO (ronag): highWaterMark? |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-runner-run.mjs +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -96,6 +96,16 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { |
96 | 96 | assert.match(stringResults[1], /tests 1/); |
97 | 97 | assert.match(stringResults[1], /pass 1/); |
98 | 98 | }); |
| 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 | + }); |
99 | 109 | }); |
100 | 110 |
|
101 | 111 | it('should be piped with tap', async () => { |
|