regenerator icon indicating copy to clipboard operation
regenerator copied to clipboard

Is it possible to regenerator just async and not generator?

Open tolmasky opened this issue 8 years ago • 1 comments

I'm now operating under an environment that supports generators out of the box. I'd still like to convert my async functions however. Babel has asyncToGenerator for this, but that seems to behave pretty differently than regeneratorRuntime.async() (no AwaitArgument, etc). So...

  1. Is regneratorRuntime.async() indeed the ideal for this situation (I feel like it is)
  2. What is the difference between what regenerator supports and the asyncToGenerator support in Babel (no handling of await + yield?).
  3. Is it possible to get regenerator to just regenerate awaits and not yields?

tolmasky avatar Sep 18 '15 01:09 tolmasky

I've been meaning to update https://www.npmjs.com/package/es7-async-await to behave more like Regenerator (i.e. do everything but transpile generators). That transform will still create a GeneratorFunction for each async function call, though, when all you really need is a single generator object.

Standards-wise, it seems like await + yield is heading in the direction of AsyncIterator, which is something Regenerator supports but es7-async-await does not (yet).

If we didn't have to deal with both await and yield, then we wouldn't need the AwaitArgument wrapper. I think the future has a place for both, though, so I'm reluctant to forbid yield just yet.

benjamn avatar Sep 18 '15 03:09 benjamn