Skip to content

Commit 541f23d

Browse files
committed
fix: Update explainer to not await values twice
See #19 (comment).
1 parent 49d651d commit 541f23d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ This of course does **not** include any code
3030
that uses ad-hoc `for await``of` loops with empty arrays:
3131
```js
3232
const arr = [];
33-
for await (const item of asyncItems) {
34-
arr.push(await item);
33+
for await (const v of asyncIterable) {
34+
arr.push(v);
3535
}
3636
```
3737
Further demonstrating the demand for such functionality,
@@ -71,7 +71,7 @@ async function * asyncGen (n) {
7171
// `arr` will be `[0, 2, 4, 6]`.
7272
const arr = [];
7373
for await (const v of asyncGen(4)) {
74-
arr.push(await v);
74+
arr.push(v);
7575
}
7676

7777
// This is equivalent.
@@ -96,7 +96,7 @@ function * genPromises (n) {
9696
// `arr` will be `[ 0, 2, 4, 6 ]`.
9797
const arr = [];
9898
for await (const v of genPromises(4)) {
99-
arr.push(await v);
99+
arr.push(v);
100100
}
101101

102102
// This is equivalent.
@@ -175,7 +175,7 @@ const arrLike = {
175175
// `arr` will be `[ 0, 2, 4, 6 ]`.
176176
const arr = [];
177177
for await (const v of Array.from(arrLike)) {
178-
arr.push(await v);
178+
arr.push(v);
179179
}
180180

181181
// This is equivalent.

0 commit comments

Comments
 (0)