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

babel-helpers

Package Overview
Dependencies
Maintainers
6
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-helpers

Collection of helper functions used by Babel transforms.

  • 6.24.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9M
decreased by-35.41%
Maintainers
6
Weekly downloads
 
Created

What is babel-helpers?

The babel-helpers npm package provides a collection of helper functions used by Babel to perform various transformations and polyfills. These helpers are used internally by Babel to handle common tasks such as class inheritance, object spread, and async/await transformations.

What are babel-helpers's main functionalities?

Class Inheritance

The `inherits` helper is used to set up prototype inheritance between two constructor functions. This is useful when you need to create a subclass that inherits from a parent class.

const inherits = require('babel-helpers').inherits;

function Parent() {}
function Child() {
  Parent.call(this);
}
inherits(Child, Parent);

Object Spread

The `objectSpread` helper is used to merge properties from multiple objects into a single object. This is similar to the object spread operator `{...obj}` in JavaScript.

const objectSpread = require('babel-helpers').objectSpread;

const obj1 = { a: 1, b: 2 };
const obj2 = { b: 3, c: 4 };
const result = objectSpread({}, obj1, obj2);
console.log(result); // { a: 1, b: 3, c: 4 }

Async/Await

The `asyncToGenerator` helper is used to transform an async function into a generator function. This is useful for environments that do not natively support async/await syntax.

const asyncToGenerator = require('babel-helpers').asyncToGenerator;

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-helpers

FAQs

Package last updated on 07 Apr 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