Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

babel-plugin-transform-regenerator

Package Overview
Dependencies
Maintainers
5
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-regenerator

Explode async and generator functions into a state machine.

latest
Source
npmnpm
Version
6.26.0
Version published
Weekly downloads
1.6M
-6.06%
Maintainers
5
Weekly downloads
 
Created
Source

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

Without options:

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

With options:

namedefault value
asyncGeneratorstrue
generatorstrue
asynctrue
{
  "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"]
});

FAQs

Package last updated on 16 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts