diff --git a/doc/api/stream.md b/doc/api/stream.md index 1ecf5162756094..a33bcdc56aa4f0 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -2644,8 +2644,8 @@ const finished = util.promisify(stream.finished); const writable = fs.createWriteStream('./file'); -async function pump(iterator, writable) { - for await (const chunk of iterator) { +async function pump(iterable, writable) { + for await (const chunk of iterable) { // Handle backpressure on write(). if (!writable.write(chunk)) { if (writable.destroyed) return; @@ -2658,7 +2658,7 @@ async function pump(iterator, writable) { (async function() { // Ensure completion without errors. await Promise.all([ - pump(iterator, writable), + pump(iterable, writable), finished(writable) ]); })(); @@ -2682,7 +2682,7 @@ const finished = util.promisify(stream.finished); const writable = fs.createWriteStream('./file'); (async function() { - const readable = Readable.from(iterator); + const readable = Readable.from(iterable); readable.pipe(writable); // Ensure completion without errors. await finished(writable); @@ -2697,7 +2697,7 @@ const pipeline = util.promisify(stream.pipeline); const writable = fs.createWriteStream('./file'); (async function() { - const readable = Readable.from(iterator); + const readable = Readable.from(iterable); await pipeline(readable, writable); })(); ```