Skip to content

Commit

Permalink
fixup! docs: fix stream async iterator sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Jan 7, 2020
1 parent 3fda730 commit f1d486a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -2650,10 +2650,10 @@ const writable = fs.createWriteStream('./file');
async function pump(iterable, writable) {
for await (const chunk of iterable) {
// Handle backpressure on write().
if (writable.destroyed) return;
if (!writable.write(chunk)) {}
if (!writable.write(chunk)) {
if (writable.destroyed) return;
await once(writable, 'drain');
if (writable.destroyed) return;
}
}
writable.end();
}
Expand Down

0 comments on commit f1d486a

Please sign in to comment.