Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
babel-plugin-transform-es2015-block-scoped-functions
Advanced tools
Babel plugin to ensure function declarations at the block level are block scoped
The babel-plugin-transform-es2015-block-scoped-functions package is a Babel plugin that transforms ES2015 block-scoped function declarations into a form that is compatible with older JavaScript environments. This is particularly useful for ensuring that code using block-scoped functions can run in environments that do not natively support ES2015 features.
Transform Block-Scoped Functions
This feature transforms block-scoped function declarations into a form that is compatible with older JavaScript environments. In the example, the function `foo` is declared within a block scope, and the plugin ensures that this code can run in environments that do not support block-scoped functions.
const babel = require('@babel/core');
const code = `{
function foo() { return 'bar'; }
}`;
const output = babel.transform(code, {
plugins: ['transform-es2015-block-scoped-functions']
});
console.log(output.code);
This package transforms block-scoped variables (let and const) and block-scoped functions into a form that is compatible with older JavaScript environments. It is more comprehensive than babel-plugin-transform-es2015-block-scoped-functions as it handles both block-scoped variables and functions.
This package ensures that function names are properly assigned in all cases, which can be useful for debugging. While it does not specifically handle block-scoped functions, it complements babel-plugin-transform-es2015-block-scoped-functions by ensuring function names are preserved.
This package transforms ES2015 function parameters (default, rest, and destructuring parameters) into a form that is compatible with older JavaScript environments. It does not handle block-scoped functions specifically but is useful for ensuring broader compatibility of ES2015 function features.
Babel plugin to ensure function declarations at the block level are block scoped.
npm install --save-dev babel-plugin-transform-es2015-block-scoped-functions
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-es2015-block-scoped-functions"]
}
babel --plugins transform-es2015-block-scoped-functions script.js
require("babel-core").transform("code", {
plugins: ["transform-es2015-block-scoped-functions"]
});
FAQs
Babel plugin to ensure function declarations at the block level are block scoped
The npm package babel-plugin-transform-es2015-block-scoped-functions receives a total of 1,695,599 weekly downloads. As such, babel-plugin-transform-es2015-block-scoped-functions popularity was classified as popular.
We found that babel-plugin-transform-es2015-block-scoped-functions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.