Socket
Socket
Sign inDemoInstall

regenerator-transform

Package Overview
Dependencies
2
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    regenerator-transform

Explode async and generator functions into a state machine.


Version published
Weekly downloads
23M
increased by2.53%
Maintainers
1
Install size
251 kB
Created
Weekly downloads
 

Package description

What is regenerator-transform?

The regenerator-transform package is a plugin for Babel that allows you to transform ES2015+ generator functions into ES5 code. It is part of the Regenerator project, which aims to enable the use of generators and async functions in environments that do not natively support them. This package is typically used in the build process of JavaScript applications to ensure compatibility with older browsers or JavaScript engines.

What are regenerator-transform's main functionalities?

Generator Function Transformation

Transforms generator functions into ES5 code using the Babel plugin system. This allows developers to write modern JavaScript with generator functions and yield syntax, and then compile it down to code that can run in older JavaScript environments.

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

Async/Await Transformation

Enables the use of async/await syntax in JavaScript code by transforming it into generator functions and then into ES5 code. This is useful for writing asynchronous code in a more synchronous style, which can be easier to read and maintain.

require('babel-core').transform('async function foo() { await bar(); }', {
  plugins: ['regenerator-transform']
});

Other packages similar to regenerator-transform

Readme

Source

regenerator-transform

Transform async/generator functions with regenerator

Installation

$ npm install regenerator-transform

Usage

.babelrc

// without options
{
  "plugins": ["regenerator-transform"]
}
// with options
{
  "plugins": [
    ["regenerator-transform", {
      asyncGenerators: false, // true by default
      generators: false, // true by default
      async: false // true by default
    }]
  ]
}

Via CLI

$ babel --plugins regenerator-transform script.js

Via Node API

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

Keywords

FAQs

Last updated on 30 Jun 2020

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc