stream: allow pass stream class to stream.compose

PR-URL: https://github.com/nodejs/node/pull/50187
Fixes: https://github.com/nodejs/node/issues/50176
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
Alex Yang authored and Michaël Zasso committed 2023-10-23 08:19:31 +02:00
1 parent 47633ab086
commit 789372a072
2 files changed
+15

No files matched your search

+5
View File
@@ -85,6 +85,11 @@ module.exports = function duplexify(body, name) {
if (typeof body === 'function') {
const { value, write, final, destroy } = fromAsyncGen(body);
// Body might be a constructor function instead of an async generator function.
if (isDuplexNodeStream(value)) {
return value;
}
if (isIterable(value)) {
return from(Duplexify, value, {
// TODO (ronag): highWaterMark?
+10
View File
@@ -96,6 +96,16 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
assert.match(stringResults[1], /tests 1/);
assert.match(stringResults[1], /pass 1/);
});
it('spec', async () => {
const result = await run({
files: [join(testFixtures, 'default-behavior/test/random.cjs')]
}).compose(spec).toArray();
const stringResults = result.map((bfr) => bfr.toString());
assert.match(stringResults[0], /this should pass/);
assert.match(stringResults[1], /tests 1/);
assert.match(stringResults[1], /pass 1/);
});
});
it('should be piped with tap', async () => {