Skip to content

Commit 960be15

Browse files
committed
stream: add comments to pipeline implementation
Fixes: #32039 PR-URL: #32042 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f69de13 commit 960be15

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/internal/streams/pipeline.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ function pipeline(...streams) {
202202
PassThrough = require('_stream_passthrough');
203203
}
204204

205+
// If the last argument to pipeline is not a stream
206+
// we must create a proxy stream so that pipeline(...)
207+
// always returns a stream which can be further
208+
// composed through `.pipe(stream)`.
209+
205210
const pt = new PassThrough();
206211
if (isPromise(ret)) {
207212
ret
@@ -236,6 +241,9 @@ function pipeline(...streams) {
236241
}
237242
}
238243

244+
// TODO(ronag): Consider returning a Duplex proxy if the first argument
245+
// is a writable. Would improve composability.
246+
// See, https://github.com/nodejs/node/issues/32020
239247
return ret;
240248
}
241249

0 commit comments

Comments
 (0)