babel-plugin-transform-regenerator
Explode async and generator functions into a state machine.
Last updated 2 years ago by hzoo .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install babel-plugin-transform-regenerator 
SYNC missed versions from official npm registry.

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
{
  "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"]
});

Current Tags

  • 6.26.0                                ...           latest (2 years ago)
  • 7.0.0-beta.3                                ...           next (2 years ago)

53 Versions

  • 7.0.0-beta.3                                ...           2 years ago
  • 7.0.0-beta.2                                ...           2 years ago
  • 7.0.0-beta.1                                ...           2 years ago
  • 7.0.0-beta.0                                ...           2 years ago
  • 7.0.0-alpha.20                                ...           2 years ago
  • 6.26.0                                ...           2 years ago
  • 7.0.0-alpha.19                                ...           2 years ago
  • 7.0.0-alpha.18                                ...           2 years ago
  • 7.0.0-alpha.17                                ...           2 years ago
  • 7.0.0-alpha.16                                ...           2 years ago
  • 7.0.0-alpha.15                                ...           2 years ago
  • 7.0.0-alpha.14                                ...           2 years ago
  • 7.0.0-alpha.12                                ...           2 years ago
  • 7.0.0-alpha.11                                ...           2 years ago
  • 7.0.0-alpha.10                                ...           2 years ago
  • 7.0.0-alpha.9                                ...           3 years ago
  • 7.0.0-alpha.8                                ...           3 years ago
  • 6.24.1                                ...           3 years ago
  • 7.0.0-alpha.7                                ...           3 years ago
  • 7.0.0-alpha.3                                ...           3 years ago
  • 7.0.0-alpha.1                                ...           3 years ago
  • 6.22.0                                ...           3 years ago
  • 6.21.0                                ...           3 years ago
  • 6.20.0                                ...           3 years ago
  • 6.16.1                                ...           3 years ago
  • 6.16.0 [deprecated]           ...           3 years ago
  • 6.14.0                                ...           3 years ago
  • 6.11.4                                ...           3 years ago
  • 6.9.0                                ...           3 years ago
  • 6.8.0                                ...           3 years ago
  • 6.6.5                                ...           4 years ago
  • 6.6.0                                ...           4 years ago
  • 6.5.2                                ...           4 years ago
  • 6.5.0-1                                ...           4 years ago
  • 6.5.0                                ...           4 years ago
  • 6.4.4                                ...           4 years ago
  • 6.4.3                                ...           4 years ago
  • 6.3.26                                ...           4 years ago
  • 6.3.18                                ...           4 years ago
  • 6.3.13                                ...           4 years ago
  • 6.3.2                                ...           4 years ago
  • 6.2.4                                ...           4 years ago
  • 6.2.0                                ...           4 years ago
  • 6.1.18                                ...           4 years ago
  • 6.1.17                                ...           4 years ago
  • 6.1.4                                ...           4 years ago
  • 6.0.18                                ...           4 years ago
  • 6.0.17                                ...           4 years ago
  • 6.0.14                                ...           4 years ago
  • 6.0.12                                ...           4 years ago
  • 6.0.10                                ...           4 years ago
  • 6.0.8                                ...           4 years ago
  • 6.0.2                                ...           4 years ago
Downloads
Today 503
This Week 19,286
This Month 144,764
Last Day 9,480
Last Week 50,313
Last Month 227,195
Dependencies (1)
Dev Dependencies (1)
Dependents (680)

Copyright 2014 - 2016 © taobao.org |