babel-plugin-transform-regenerator
    Overview
    Documentation
    Code
    Playground
    Issues
    Insights
    Contributors
    Dependencies
    Versions
    Alternatives

babel-plugin-transform-regenerator

Explode async and generator functions into a state machine.

6.26.0  •  Published 2 years ago  •  by Ben Newman  •  MIT License

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
{
  "plugins": [
    ["transform-regenerator", {
      "asyncGenerators": false,
      "generators": false,
      "async": false
    }]
  ]
}

Via CLI

babel --plugins transform-regenerator script.js

Via Node API

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

Popularity

Weekly Downloads
2.4M

Maintenance

Development

Last ver 2 years ago
Created 4 years ago
Last commit 1 second ago
1 second between commits

Technology

Node version: 6.9.0
0 unpacked

Legal and Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

0 contributors