Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

regenerator

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regenerator

Source transformer enabling ECMAScript 6 generator functions (yield) in JavaScript-of-today (ES5)

  • 0.9.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
241K
increased by24.76%
Maintainers
1
Weekly downloads
 
Created

What is regenerator?

The regenerator npm package is a tool that transforms ECMAScript 2015+ (ES6+) generator functions and async functions into a form that can be used in older JavaScript environments. It allows developers to use modern JavaScript features while maintaining compatibility with older browsers and environments.

What are regenerator's main functionalities?

Transforming Generator Functions

This feature allows you to write generator functions using the `function*` syntax and transform them into code that can run in environments that do not natively support generators.

const regeneratorRuntime = require('regenerator-runtime/runtime');

function* generatorFunction() {
  yield 'Hello';
  yield 'World';
}

const gen = generatorFunction();
console.log(gen.next().value); // 'Hello'
console.log(gen.next().value); // 'World'

Transforming Async Functions

This feature allows you to write async functions using the `async` and `await` syntax and transform them into code that can run in environments that do not natively support async functions.

const regeneratorRuntime = require('regenerator-runtime/runtime');

async function asyncFunction() {
  return await Promise.resolve('Hello World');
}

asyncFunction().then(console.log); // 'Hello World'

Other packages similar to regenerator

Keywords

FAQs

Package last updated on 01 Dec 2016

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc