tc39 / proposal-array-from-async

Draft specification for a proposed Array.fromAsync method in JavaScript.
http://tc39.es/proposal-array-from-async/
BSD 3-Clause "New" or "Revised" License
179 stars 13 forks source link

Why missed a fallback to sync @@iterator? #6

Closed zloirock closed 3 years ago

zloirock commented 3 years ago
for await (const it of [Promise.resolve(1), 2, Promise.resolve(3)]) console.log(it); // => 1, 2, 3

await AsyncIterator.from([Promise.resolve(1), 2, Promise.resolve(3)]).toArray(); // => [1, 2, 3]

// but:
await Array.fromAsync([Promise.resolve(1), 2, Promise.resolve(3)]); // => TypeError

image

js-choi commented 3 years ago

This is an oversight. Thanks for catching it. I will fix it in the future.