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

babel-runtime

Package Overview
Dependencies
Maintainers
5
Versions
191
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-runtime

babel selfContained runtime

  • 6.26.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.3M
decreased by-17.7%
Maintainers
5
Weekly downloads
 
Created

What is babel-runtime?

The babel-runtime npm package is a part of Babel, a JavaScript compiler that allows developers to use next-generation JavaScript, today. It provides runtime support for features that are not supported in older browsers or environments. This includes things like new syntax features and built-in functions. The babel-runtime package helps in avoiding polluting the global scope and reduces the code size by deduplicating helper functions that Babel uses to transpile the code.

What are babel-runtime's main functionalities?

Polyfill for ECMAScript features

This code sample demonstrates how babel-runtime can be used to polyfill newer ECMAScript features such as Promises for environments that do not support them natively.

import 'babel-runtime/core-js/promise';

const p = new Promise((resolve, reject) => {
  setTimeout(resolve, 1000, 'foo');
});

Transforming syntax

This code sample shows how babel-runtime provides helper functions to transform syntax like classes into a format that can be understood by environments that do not support such syntax natively.

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

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

Regenerator for generators and async functions

This code sample illustrates the use of babel-runtime to enable the use of async functions and generators in environments that do not have native support for these features.

import 'babel-runtime/regenerator';

async function asyncCall() {
  console.log('calling');
  const result = await resolveAfter2Seconds();
  console.log(result);
}

Other packages similar to babel-runtime

FAQs

Package last updated on 16 Aug 2017

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