Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
regenerator-transform
Advanced tools
Explode async and generator functions into a state machine.
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.
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']
});
This package is a Babel plugin that specifically transforms async functions into generator functions. It is similar to regenerator-transform but focuses only on async/await syntax, not on general generator functions.
babel-preset-env is a Babel preset that includes regenerator-transform as one of its plugins. It allows developers to specify the target environments for their code and automatically includes the necessary plugins and polyfills to support those environments, including transformations for generators and async functions.
fast-async is a Babel plugin that uses the nodent compiler to transform async/await syntax into Promises instead of generator functions. It provides a faster alternative to regenerator-transform for handling async functions, but does not handle generator functions.
Transform async/generator functions with regenerator
$ npm install regenerator-transform
.babelrc
(Recommended).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
}]
]
}
$ babel --plugins regenerator-transform script.js
require("@babel/core").transformSync("code", {
plugins: ["regenerator-transform"]
});
FAQs
Explode async and generator functions into a state machine.
The npm package regenerator-transform receives a total of 19,711,002 weekly downloads. As such, regenerator-transform popularity was classified as popular.
We found that regenerator-transform demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.