GeezerVison is showing github.com — stream: allow pass stream class to `stream.compose` · nodejs/node@ffdc357
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 |
|---|
@@ -104,6 +104,16 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { |
104 | 104 | assert.match(stringResults[1], /tests 1/); |
105 | 105 | assert.match(stringResults[1], /pass 1/); |
106 | 106 | }); |
| 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 | + }); |
107 | 117 | }); |
108 | 118 |
|
109 | 119 | it('should be piped with tap', async () => { |
|