Skip to content

Commit d326843

Browse files
authored
docs: Fix mapping-function example
1 parent 2bf3c7c commit d326843

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ because the result of the `x => x` mapping function is awaited.
267267
For example:
268268
269269
```js
270-
function as () {
270+
function createAsyncIter () {
271+
let i = 0;
271272
return {
272273
[Symbol.asyncIterator]() {
273274
return {
@@ -282,10 +283,10 @@ function as () {
282283
}
283284

284285
// This prints `[Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)]`:
285-
console.log(await Array.fromAsync(it));
286+
console.log(await Array.fromAsync(createAsyncIter()));
286287

287288
// This prints `[1, 2, 3]`:
288-
console.log(await Array.fromAsync(it, x => x));
289+
console.log(await Array.fromAsync(createAsyncIter(), x => x));
289290
```
290291
291292
See also [issue #19](https://github.com/tc39/proposal-array-from-async/issues/19).

0 commit comments

Comments
 (0)