proposal-array-from-async icon indicating copy to clipboard operation
proposal-array-from-async copied to clipboard

Sharing machinary with iterator-helpers toArray

Open benjamingr opened this issue 4 years ago • 4 comments

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)

benjamingr avatar Jan 17 '22 17:01 benjamingr

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.

ljharb avatar Jan 17 '22 17:01 ljharb

That sounds reasonable to me.

benjamingr avatar Jan 17 '22 17:01 benjamingr

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.

zloirock avatar Jan 17 '22 18:01 zloirock

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.

js-choi avatar Jan 17 '22 19:01 js-choi