tc39 / proposal-async-iterator-helpers

Methods for working with async iterators in ECMAScript
https://tc39.es/proposal-async-iterator-helpers/
107 stars 3 forks source link

should AsyncIterator.prototype have a toAsync method as well? #23

Open michaelficarra opened 4 months ago

michaelficarra commented 4 months ago

AsyncIterator.prototype will have all the same method names as Iterator.prototype. But this proposal also adds toAsync to Iterator.prototype. So will AsyncIterator.prototype have a toAsync that basically no-ops? What are the pros and cons?

This has consequences on the design of unordered async iterator helpers and whether their prototype has an unordered method or whether that just gets added to AsyncIterator.prototype.

bakkot commented 4 months ago

Pro is that you can call it for something which you know to be either an iterator or async iterator but not which, I guess? But that's a pretty unusual case, and in any case you could just do AsyncIterator.from(x), so I don't see much reason to add this.

ljharb commented 4 months ago

I suppose one could do ?.toAsync()?

michaelficarra commented 3 months ago

In plenary, during the unordered async iterator helpers discussion, @erights preferred including this method.