-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Labels
promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
With async iterators, we can use synchronous-looking code to consume readable streams.
There is no equivalent for writable streams in Node core.
Example use case:
const fs = require('fs');
const zlib = require('zlib');
(async () => {
const read = fs.createReadStream('data.txt.gz');
const gunzip = zlib.createGunzip();
const write = fs.createWriteStream('data.txt');
await read.pipe(gunzip).pipe(write);
})();This would resolve when write ends or reject if an error occurs.
Prior art:
- https://github.com/bendrucker/stream-to-promise
- https://github.com/epeli/node-promisepipe
- https://github.com/dex4er/js-promise-writable
/cc @nodejs/streams @mcollina
Metadata
Metadata
Assignees
Labels
promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.