Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2a1e4e9

Browse filesBrowse files
LxxyxBethGriggs
authored andcommitted
stream: accept iterable as a valid first argument
Fixes: #36437 PR-URL: #36479 Backport-PR-URL: #36831 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 9c438b5 commit 2a1e4e9
Copy full SHA for 2a1e4e9

File tree

Expand file treeCollapse file tree

2 files changed

+20
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+20
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/streams/pipeline.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/pipeline.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ async function pump(iterable, writable, finish) {
142142
function pipeline(...streams) {
143143
const callback = once(popCallback(streams));
144144

145-
if (ArrayIsArray(streams[0])) streams = streams[0];
145+
// stream.pipeline(streams, callback)
146+
if (ArrayIsArray(streams[0]) && streams.length === 1) {
147+
streams = streams[0];
148+
}
146149

147150
if (streams.length < 2) {
148151
throw new ERR_MISSING_ARGS('streams');
Collapse file

‎test/parallel/test-stream-pipeline.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-pipeline.js
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,3 +1216,19 @@ const net = require('net');
12161216
assert.strictEqual(res, 'helloworld');
12171217
}));
12181218
}
1219+
1220+
{
1221+
pipeline([1, 2, 3], PassThrough({ objectMode: true }),
1222+
common.mustSucceed(() => {}));
1223+
1224+
let res = '';
1225+
const w = new Writable({
1226+
write(chunk, encoding, callback) {
1227+
res += chunk;
1228+
callback();
1229+
},
1230+
});
1231+
pipeline(['1', '2', '3'], w, common.mustSucceed(() => {
1232+
assert.strictEqual(res, '123');
1233+
}));
1234+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.