asyncToGenerator

How to use the asyncToGenerator transformer.

Transforms async functions to a generator that uses a helper. This is useful if you don't want to use regenerator or bluebird.

Usage

require("babel").transform("code", { optional: ["asyncToGenerator"] });
$ babel --optional asyncToGenerator script.js

Example

In

async function foo() {
  await bar();
}

Out

var _asyncToGenerator = function (fn) {
  ...
};

var foo = _asyncToGenerator(function* () {
  yield bar();
});