Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
regenerator-runtime
Advanced tools
Runtime for Regenerator-compiled generator and async functions.
The regenerator-runtime package is a runtime module for Regenerator-compiled generator and async functions. It provides a polyfill for environments that do not natively support these features, allowing developers to use generators and async/await syntax in their JavaScript code.
Generator Function Support
Enables the use of generator functions, which can yield multiple values over time, allowing for more control over asynchronous operations.
function* gen() {
yield 1;
yield 2;
yield 3;
}
const g = gen();
console.log(g.next().value); // 1
console.log(g.next().value); // 2
console.log(g.next().value); // 3
Async/Await Support
Allows the use of async/await syntax for writing asynchronous code in a more synchronous fashion, improving readability and maintainability.
async function fetchData() {
const data = await fetch('https://api.example.com/data');
return data.json();
}
fetchData().then(data => console.log(data));
Babel-polyfill includes regenerator-runtime along with a full ES2015+ environment polyfill. It is more comprehensive but also larger in size compared to regenerator-runtime, which focuses only on generator and async function support.
Core-js is a modular standard library for JavaScript, which includes polyfills for ECMAScript features. It provides similar functionality to regenerator-runtime but also includes polyfills for other features such as Promises, Symbols, Collections, Iterators, and more.
While not providing generator or async function support, es6-promise is a lightweight library that offers a polyfill for Promises, which are often used in conjunction with async/await syntax. It is more focused compared to regenerator-runtime, which provides broader support for ES2015+ features.
Standalone runtime for
Regenerator-compiled generator
and async
functions.
To import the runtime as a module (recommended), either of the following import styles will work:
// CommonJS
const regeneratorRuntime = require("regenerator-runtime");
// ECMAScript 2015
import regeneratorRuntime from "regenerator-runtime";
To ensure that regeneratorRuntime
is defined globally, either of the
following styles will work:
// CommonJS
require("regenerator-runtime/runtime");
// ECMAScript 2015
import "regenerator-runtime/runtime.js";
To get the absolute file system path of runtime.js
, evaluate the
following expression:
require("regenerator-runtime/path").path
FAQs
Runtime for Regenerator-compiled generator and async functions.
The npm package regenerator-runtime receives a total of 60,173,378 weekly downloads. As such, regenerator-runtime popularity was classified as popular.
We found that regenerator-runtime demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.