Proposal: Support Asynchronous Iterators

Asynchronous iterators are increasingly well-supported. Should CoffeeScript 2 provide first-class support for them?

This would require supporting an additional for syntax corresponding to for await … of in JavaScript. Perhaps CoffeeScript can add for await … from?

The problem here is analogous to the problem that inspired for … from—namely, you cannot use for loops naturally with async iterators otherwise.

In addition, it would require allowing functions that contain both await and yield and generating async function* declarations, aka async generator functions.

1 possible answer(s) on “Proposal: Support Asynchronous Iterators

  1. This is normally where I squash the party and say that we need to wait for Stage 4, blah blah, but actually . . . async iterators reached Stage 4 last month! So yes, definitely, let’s add this.

    You are correct, the CoffeeScript version would need to use from, as that’s our keyword that equates to of. You’d think that with all the copying of CoffeeScript that the ECMA committee did, they could’ve avoided using of for something different than what we use it for. But we can’t change things now.

    So yes, if you or someone else would like to implement for await … from, and remove the current errors that the compiler throws when trying to combine await and iterators, that would be welcomed.