vlad 6f123ff03e 18.07 | 6 سال پیش | |
---|---|---|
.. | ||
lib | 6 سال پیش | |
.npmignore | 6 سال پیش | |
README.md | 6 سال پیش | |
package-lock.json | 6 سال پیش | |
package.json | 6 سال پیش |
Transform async/generator functions with regenerator
In
function* a() {
yield 1;
}
Out
var _marked = [a].map(regeneratorRuntime.mark);
function a() {
return regeneratorRuntime.wrap(function a$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return 1;
case 2:
case "end":
return _context.stop();
}
}
}, _marked[0], this);
}
npm install --save-dev babel-plugin-transform-regenerator
.babelrc
(Recommended)Without options:
{
"plugins": ["transform-regenerator"]
}
With options:
name | default value |
---|---|
asyncGenerators | true |
generators | true |
async | true |
{
"plugins": [
["transform-regenerator", {
"asyncGenerators": false,
"generators": false,
"async": false
}]
]
}
babel --plugins transform-regenerator script.js
require("babel-core").transform("code", {
plugins: ["transform-regenerator"]
});