This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Description
One challenge I have found with using async iteration is that it is challenging to do basic functionality like map in a way that works properly with return/throw. For example, it would look like one could implement map like:
async function* map(it, f) {
for await (const x of it) {
yield f(x);
}
}
but calling .return on the value returned from map doesn't actually call it.return immediately if it's blocked on reading from it, which can have poor results. You can build a map that does pass through it.return immediately but it's much harder than writing an async generator. Lots of discussion about that on this issue.
So my question, having recently discovered this proposal, is: does this proposal help with this concern? If you return an async iterator returned by .map(fn) for example, is that passed through to the original iterator immediately, or only if it's currently yielding? I can't figure out the answer myself from README.md or DETAILs.md, and I don't understand the specification well enough to answer it myself there.