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
177 stars 13 forks source link

Sharing machinary with iterator-helpers toArray #23

Open benjamingr opened 2 years ago

benjamingr commented 2 years ago

Hey, I was wondering, since Array.fromAsync(iter) is similar to AsyncIterator.from(iter).toArray() wouldn't it make sense if they shared the same spec text? That is one (for example fromAsync) is defined and the other is defined in terms of it?

(I agree that it makes sense to have both as it's more ergonomic and people will likely reach out to both - though that's not the discussion here)

ljharb commented 2 years ago

Certainly it'd be ideal if they shared steps via abstract operations, but that'd likely happen after one of them had landed in the main spec.

benjamingr commented 2 years ago

That sounds reasonable to me.

zloirock commented 2 years ago

For sharing this logic, this difference should be resolved https://github.com/tc39/proposal-iterator-helpers/issues/168. At this moment, core-js use one internal operation for them.

js-choi commented 2 years ago

We will discuss this issue (as well as #19 and tc39/proposal-iterator-helpers#168) when we present this proposal for Stage 3 at the upcoming plenary meeting.

We could try isolating the algorithm into its own abstract operation soon in anticipation of iterator-helpers. It’s just an editorial thing.

Related: #1, #19, tc39/proposal-iterator-helpers#36, tc39/proposal-iterator-helpers#142, tc39/proposal-iterator-helpers#156.