GitHub · npm · Edit this page
This plugin allows Babel to transform async functions into a Bluebird coroutine.
In
async function foo() {
await bar();
}
Out
var Bluebird = require("bluebird");
var foo = Bluebird.coroutine(function* () {
yield bar();
});
npm install --save-dev babel-plugin-transform-async-to-module-method
.babelrc
(Recommended).babelrc
Without options:
{
"plugins": ["transform-async-to-module-method"]
}
With options:
{
"plugins": [
["transform-async-to-module-method", {
"module": "bluebird",
"method": "coroutine"
}]
]
}
babel --plugins transform-async-to-module-method script.js
require("babel-core").transform("code", {
plugins: ["transform-async-to-module-method"]
});