stream: add comments to pipeline implementation

Fixes: https://github.com/nodejs/node/issues/32039

PR-URL: https://github.com/nodejs/node/pull/32042
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Robert Nagy committed 2020-03-07 18:17:54 +01:00
1 parent f69de13bfe
commit 960be159ac
1 file changed
+8
+8
View File
@@ -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
@@ -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;
}