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 <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
ronag authored and MylesBorins committed Mar 9, 2020
1 parent 3befe80 commit 2585b81
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/internal/streams/pipeline.js
Expand Up @@ -219,6 +219,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 @@ -253,6 +258,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 2585b81

Please sign in to comment.