huanggang 03a863fb53 add node_modules 7 年之前
..
lib 03a863fb53 add node_modules 7 年之前
.npmignore 03a863fb53 add node_modules 7 年之前
README.md 03a863fb53 add node_modules 7 年之前
package.json 03a863fb53 add node_modules 7 年之前

README.md

babel-plugin-transform-regenerator

Transform async/generator functions with regenerator

Example

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);
}

Installation

npm install --save-dev babel-plugin-transform-regenerator

Usage

Via .babelrc (Recommended)

Without options:

{
  "plugins": ["transform-regenerator"]
}

With options:

name default value
asyncGenerators true
generators true
async true

````json { "plugins": [

["transform-regenerator", {
  asyncGenerators: false,
  generators: false,
  async: false
}]

] }


### Via CLI

```sh
babel --plugins transform-regenerator script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-regenerator"]
});