Skip to content

Commit

Permalink
stream: add comments to pipeline implementation
Browse files Browse the repository at this point in the history
Fixes: #32039

PR-URL: #32042
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
ronag committed Mar 7, 2020
1 parent f69de13 commit 960be15
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/internal/streams/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ function pipeline(...streams) {
PassThrough = require('_stream_passthrough');
}

// If the last argument to pipeline is not a stream
// we must create a proxy stream so that pipeline(...)
// always returns a stream which can be further
// composed through `.pipe(stream)`.

const pt = new PassThrough();
if (isPromise(ret)) {
ret
Expand Down Expand Up @@ -236,6 +241,9 @@ function pipeline(...streams) {
}
}

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

Expand Down

0 comments on commit 960be15

Please sign in to comment.