I think @bakkot gives some persuasive points, especially that the mapping function is actually essentially an async function, so it wouldn’t make sense for its identity to be x => x.
My priorities, in order, have always been:
-
Array.fromAsync(i)must be equivalent toArray.fromAsync(i, undefined)andArray.fromAsync(i, null). (For optional parameters, nullish arguments should be functionally equivalent to omitting the arguments. This is how every function in the core language is designed, and I believe it is also an explicit best practice in Web APIs.) -
Array.fromAsync(i)must be equivalent tofor await (const v of i). (The default case offromAsyncmust match intuitions aboutfor await (of), just like howfrommatches intuitions aboutfor (of).) -
Array.fromAsync(i)should be equivalent toAsyncIterator.from(i).toArray().