Skip to content

stream: make streams thenable

Make streams thenable as a shortcut to finished(stream).

Together with https://github.com/nodejs/node/pull/39029 this would provide a quite nice API without requiring importing helpers such as finished and pipeline.

e.g.

await Duplex.from(
  fs.createReadStream('file. txt'),
  createGzip(),
  fs.createWriteStream('file. txt.gz')
)

instead of:

for await (const dummy of Duplex.from(
  fs.createReadStream('file. txt'),
  createGzip(),
  fs.createWriteStream('file. txt.gz')
)) {
  // do nothing
}

Merge request reports

Loading