Skip to content

Commit 2585b81

Browse files
ronagMylesBorins
authored andcommitted
stream: add comments to pipeline implementation
Fixes: #32039 PR-URL: #32042 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 3befe80 commit 2585b81

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/internal/streams/pipeline.js

+8
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ function pipeline(...streams) {
219219
PassThrough = require('_stream_passthrough');
220220
}
221221

222+
// If the last argument to pipeline is not a stream
223+
// we must create a proxy stream so that pipeline(...)
224+
// always returns a stream which can be further
225+
// composed through `.pipe(stream)`.
226+
222227
const pt = new PassThrough();
223228
if (isPromise(ret)) {
224229
ret
@@ -253,6 +258,9 @@ function pipeline(...streams) {
253258
}
254259
}
255260

261+
// TODO(ronag): Consider returning a Duplex proxy if the first argument
262+
// is a writable. Would improve composability.
263+
// See, https://github.com/nodejs/node/issues/32020
256264
return ret;
257265
}
258266

0 commit comments

Comments
 (0)