Skip to content

Commit

Permalink
stream: add comments to pipeline implementation
Browse files Browse the repository at this point in the history
Fixes: #32039
  • Loading branch information
ronag committed Mar 2, 2020
1 parent 1e8625c commit c374648
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 @@ -188,6 +188,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 @@ -222,6 +227,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 c374648

Please sign in to comment.