Socket
Socket
Sign inDemoInstall

babel-plugin-transform-es2015-block-scoping

Package Overview
Dependencies
Maintainers
5
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-es2015-block-scoping

Compile ES2015 block scoping (const and let) to ES5


Version published
Weekly downloads
1.6M
increased by12.15%
Maintainers
5
Weekly downloads
 
Created

What is babel-plugin-transform-es2015-block-scoping?

The babel-plugin-transform-es2015-block-scoping package is a Babel plugin that transforms ES2015 block scoping (let and const) to ES5. This is useful for ensuring compatibility with older JavaScript environments that do not support ES2015 features.

What are babel-plugin-transform-es2015-block-scoping's main functionalities?

Transform let to var

This feature transforms ES2015 let declarations to ES5 var declarations, ensuring compatibility with older JavaScript environments.

const babel = require('@babel/core');
const code = 'let x = 1;';
const output = babel.transform(code, { plugins: ['babel-plugin-transform-es2015-block-scoping'] });
console.log(output.code); // var x = 1;

Transform const to var

This feature transforms ES2015 const declarations to ES5 var declarations, ensuring compatibility with older JavaScript environments.

const babel = require('@babel/core');
const code = 'const y = 2;';
const output = babel.transform(code, { plugins: ['babel-plugin-transform-es2015-block-scoping'] });
console.log(output.code); // var y = 2;

Block scoping with loops

This feature ensures that block-scoped variables within loops are transformed to function-scoped variables, maintaining the correct scoping behavior in older JavaScript environments.

const babel = require('@babel/core');
const code = 'for (let i = 0; i < 5; i++) { console.log(i); }';
const output = babel.transform(code, { plugins: ['babel-plugin-transform-es2015-block-scoping'] });
console.log(output.code); // for (var i = 0; i < 5; i++) { console.log(i); }

Other packages similar to babel-plugin-transform-es2015-block-scoping

Keywords

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