proposal-iterator-helpers icon indicating copy to clipboard operation
proposal-iterator-helpers copied to clipboard

fixes #230: don't await non-objects returned from functions passed to AsyncIterator HoFs

Open michaelficarra opened this issue 3 years ago • 5 comments

Fixes #230. This is only observable in the number of ticks taken to complete the method. It is always at least 1 because the async iteration protocol itself requires awaiting the IteratorResult object, so no Zalgo issues.

michaelficarra avatar Sep 26 '22 21:09 michaelficarra

Maybe makes sense somehow to extend it to awaiting only thenables? However, sure, it's not so simple and is controversial.

zloirock avatar Sep 26 '22 22:09 zloirock

Why would we want to do this here when we don't do it for await itself?

ljharb avatar Sep 26 '22 22:09 ljharb

It would be weird if a syntactic await did not in fact wait. But there's no syntactic await here.

bakkot avatar Sep 26 '22 22:09 bakkot

No, but there's the equivalent of a return from an async function, which i'd expect to say the same.

ljharb avatar Sep 26 '22 23:09 ljharb

It's true we could reasonably have had this fast-path there as well. Probably still could, for that matter.

bakkot avatar Sep 26 '22 23:09 bakkot