From 1f15d7539578a877146b84145c80a26920b321d2 Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Wed, 24 Jul 2019 01:28:09 +0800 Subject: [PATCH] doc: api/stream.md typo from writeable to writable PR-URL: https://github.com/nodejs/node/pull/28822 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: Richard Lau --- doc/api/stream.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 63c34aa666eb94..f33a18f9aef8c9 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -2504,23 +2504,23 @@ readable.on('data', (chunk) => { #### Piping to Writable Streams from Async Iterators -In the scenario of writing to a writeable stream from an async iterator, +In the scenario of writing to a writable stream from an async iterator, it is important to ensure the correct handling of backpressure and errors. ```js const { once } = require('events'); -const writeable = fs.createWriteStream('./file'); +const writable = fs.createWriteStream('./file'); (async function() { for await (const chunk of iterator) { // Handle backpressure on write(). - if (!writeable.write(chunk)) - await once(writeable, 'drain'); + if (!writable.write(chunk)) + await once(writable, 'drain'); } - writeable.end(); + writable.end(); // Ensure completion without errors. - await once(writeable, 'finish'); + await once(writable, 'finish'); })(); ``` @@ -2533,13 +2533,13 @@ then piped via `.pipe()`: ```js const { once } = require('events'); -const writeable = fs.createWriteStream('./file'); +const writable = fs.createWriteStream('./file'); (async function() { const readable = Readable.from(iterator); - readable.pipe(writeable); + readable.pipe(writable); // Ensure completion without errors. - await once(writeable, 'finish'); + await once(writable, 'finish'); })(); ```