Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

add for-await-of desugared example to readme #128

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ for await (const line of readLines(filePath)) {
}
```

This is equivalent to:

```js
for (const _ of readLines(filePath)) {
const line = await _;
console.log(line);
}
```

Async for-of statements are only allowed within async functions and async generator functions (see below for the latter).

During execution, an async iterator is created from the data source using the `[Symbol.asyncIterator]()` method.
Expand Down