Skip to content
Permalink
Browse files

doc: api/stream.md typo from writeable to writable

PR-URL: #28822
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
  • Loading branch information...
imcotton authored and trivikr committed Jul 23, 2019
1 parent dcb6929 commit bd3b85bf89df16515ad79b537da02b8a6d3fba55
Showing with 9 additions and 9 deletions.
  1. +9 −9 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');
})();
```

0 comments on commit bd3b85b

Please sign in to comment.
You can’t perform that action at this time.