Skip to content

Commit

Permalink
fixup! readline: add support for async iteration
Browse files Browse the repository at this point in the history
Documentation changes
  • Loading branch information
TimothyGu committed Nov 20, 2018
1 parent 179dd7b commit f8ff7c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion doc/api/readline.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,17 @@ Create an `AsyncIterator` object that iterates through each line in the input
stream as a string. This method allows asynchronous iteration of
`readline.Interface` objects through `for`-`await`-`of` loops.

*Note:* Errors in the input stream are not forwarded.
Errors in the input stream are not forwarded.

If the loop is terminated with `break`, `throw`, or `return`,
[`rl.close()`][] will be called. In other words, iterating over a
`readline.Interface` will always consume the input stream fully.

A caveat with using this experimental API is that the performance is
currently not on par with the traditional `'line'` event API, and thus it is
not recommended for performance-sensitive applications. We expect this
situation to improve in the future.

```js
async function processLineByLine() {
const rl = readline.createInterface({
Expand Down

0 comments on commit f8ff7c7

Please sign in to comment.