* moved applying arguments inside new Promise handler block * updated test fixture to reflect change * corrected the apply to use correct scope and arguments * added regression test for issue #4943, added async-to-generator/async-default-arguments test * added regression test for issue #4943 * switched back to using arrow function, since now pointing to v7 release base branch * simplified async-to-generator regression test for issue #4943, imrproved change to self/arguments refs by using arrow function on returned promise * updated text fixtures * removed es2015 preset usage from issue #4943 regression exec test * added use strict to test fixture * added use strict to test fixture * added destructing transform to test options * removed use strict from exec test * added parameters & destructing transforms to test
babel-plugin-transform-async-to-generator
Turn async functions into ES2015 generators
Example
In
async function foo() {
await bar();
}
Out
var _asyncToGenerator = function (fn) {
...
};
var foo = _asyncToGenerator(function* () {
yield bar();
});
Installation
npm install --save-dev babel-plugin-transform-async-to-generator
Usage
Via .babelrc (Recommended)
.babelrc
{
"plugins": ["transform-async-to-generator"]
}
Via CLI
babel --plugins transform-async-to-generator script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["transform-async-to-generator"]
});