babel/packages/babel-plugin-transform-async-to-module-method
Justin Ridgewell 3e487f89ab Don't merge test options. (#6157)
* Don't merge test options.

Particularly, I don't want `lodash/merge` to merge my specific plugins
with the general test plugins. It led to odd behavior where I could
enable a loose transform in my specific test, just to have it overridden
by the test fixture's general options.

* Need options
2017-08-28 13:36:03 -06:00
..
2017-06-27 12:15:00 -05:00
2017-08-28 13:36:03 -06:00
2017-03-25 21:46:16 -04:00
2017-08-07 18:21:08 -04:00

babel-plugin-transform-async-to-module-method

Turn async functions into a Bluebird coroutine

Example

In

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

Out

var Bluebird = require("bluebird");

var foo = Bluebird.coroutine(function* () {
  yield bar();
});

Installation

npm install --save-dev babel-plugin-transform-async-to-module-method

Usage

.babelrc

Without options:

{
  "plugins": ["transform-async-to-module-method"]
}

With options:

{
  "plugins": [
    ["transform-async-to-module-method", {
      "module": "bluebird",
      "method": "coroutine"
    }]
  ]
}

Via CLI

babel --plugins transform-async-to-module-method script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-async-to-module-method"]
});