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

@babel/runtime-corejs2

Package Overview
Dependencies
Maintainers
4
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/runtime-corejs2

babel's modular runtime helpers with core-js@2 polyfilling

  • 7.19.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
538K
decreased by-27.42%
Maintainers
4
Weekly downloads
 
Created

What is @babel/runtime-corejs2?

@babel/runtime-corejs2 is a library that provides a runtime for Babel that includes polyfills for ECMAScript features using core-js@2. It helps to avoid code duplication and reduce the size of the compiled code by providing helpers and polyfills as separate modules.

What are @babel/runtime-corejs2's main functionalities?

Polyfilling ECMAScript features

This feature allows you to polyfill ECMAScript features like Map and Set, ensuring compatibility with older environments that do not support these features natively.

import 'core-js/es6/map';
import 'core-js/es6/set';

const map = new Map();
const set = new Set();

Helper functions

This feature provides helper functions like classCallCheck to ensure that classes are instantiated correctly, which is useful for maintaining compatibility with older JavaScript environments.

import _classCallCheck from '@babel/runtime-corejs2/helpers/classCallCheck';

class MyClass {
  constructor() {
    _classCallCheck(this, MyClass);
  }
}

Async/Await support

This feature provides support for async/await syntax by transforming it into generator functions, which are compatible with older JavaScript environments.

import _asyncToGenerator from '@babel/runtime-corejs2/helpers/asyncToGenerator';
import regeneratorRuntime from 'regenerator-runtime';

const asyncFunction = _asyncToGenerator(function* () {
  const result = yield fetch('https://api.example.com/data');
  return result.json();
});

asyncFunction().then(data => console.log(data));

Other packages similar to @babel/runtime-corejs2

FAQs

Package last updated on 14 Sep 2022

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