mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
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:
1 parent
47633ab086
commit
789372a072
2 files changed
+15
No files matched your search
@@ -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?
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in new issue
Block a user