doc: reformat for-await-of
Instead of `for`-`await`-`of`, prefer `for await...of`. PR-URL: https://github.com/nodejs/node/pull/28425 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
d22fbbe942
commit
6045fbbb5e
@ -322,7 +322,7 @@ changes:
|
|||||||
|
|
||||||
Create an `AsyncIterator` object that iterates through each line in the input
|
Create an `AsyncIterator` object that iterates through each line in the input
|
||||||
stream as a string. This method allows asynchronous iteration of
|
stream as a string. This method allows asynchronous iteration of
|
||||||
`readline.Interface` objects through `for`-`await`-`of` loops.
|
`readline.Interface` objects through `for await...of` loops.
|
||||||
|
|
||||||
Errors in the input stream are not forwarded.
|
Errors in the input stream are not forwarded.
|
||||||
|
|
||||||
@ -556,7 +556,7 @@ rl.on('line', (line) => {
|
|||||||
|
|
||||||
A common use case for `readline` is to consume an input file one line at a
|
A common use case for `readline` is to consume an input file one line at a
|
||||||
time. The easiest way to do so is leveraging the [`fs.ReadStream`][] API as
|
time. The easiest way to do so is leveraging the [`fs.ReadStream`][] API as
|
||||||
well as a `for`-`await`-`of` loop:
|
well as a `for await...of` loop:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
@ -597,7 +597,7 @@ rl.on('line', (line) => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Currently, `for`-`await`-`of` loop can be a bit slower. If `async` / `await`
|
Currently, `for await...of` loop can be a bit slower. If `async` / `await`
|
||||||
flow and speed are both essential, a mixed approach can be applied:
|
flow and speed are both essential, a mixed approach can be applied:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
Loading…
x
Reference in New Issue
Block a user