
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
babel-plugin-transform-es2015-parameters
Advanced tools
Compile ES2015 default and rest parameters to ES5
The babel-plugin-transform-es2015-parameters package is a Babel plugin that transforms ES2015 (ES6) parameter features to ES5. This includes default parameters, rest parameters, and destructuring in function parameters.
Default Parameters
This feature allows you to set default values for function parameters. If no argument is provided for the parameter, the default value is used.
function greet(name = 'World') { console.log('Hello ' + name); } greet(); // Hello World greet('Alice'); // Hello Alice
Rest Parameters
Rest parameters allow you to represent an indefinite number of arguments as an array. This is useful for functions that need to handle a variable number of arguments.
function sum(...numbers) { return numbers.reduce((acc, num) => acc + num, 0); } console.log(sum(1, 2, 3)); // 6
Destructuring in Parameters
Destructuring in function parameters allows you to unpack values from objects or arrays directly in the parameter list. This can make your code more readable and concise.
function printCoordinates({ x, y }) { console.log(`X: ${x}, Y: ${y}`); } printCoordinates({ x: 10, y: 20 }); // X: 10, Y: 20
This package transforms ES2015 destructuring syntax to ES5. It focuses specifically on destructuring assignments and function parameters, similar to the destructuring feature in babel-plugin-transform-es2015-parameters.
This package transforms ES2015 spread syntax to ES5. While it focuses on spread operations, it complements the rest parameters feature of babel-plugin-transform-es2015-parameters by handling array and object spread.
This package ensures that function names are correctly assigned in ES2015. It is not directly related to parameters but is often used alongside parameter transformation plugins to ensure function names are preserved.
Compile ES2015 default and rest parameters to ES5
This plugin transforms ES2015 parameters to ES5, this includes:
npm install --save-dev babel-plugin-transform-es2015-parameters
Default parameters desugar into let
declarations to retain proper semantics. If this is
not supported in your environment then you'll need the
transform-block-scoping plugin.
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-es2015-parameters"]
}
babel --plugins transform-es2015-parameters script.js
require("babel-core").transform("code", {
plugins: ["transform-es2015-parameters"]
});
FAQs
Compile ES2015 default and rest parameters to ES5
The npm package babel-plugin-transform-es2015-parameters receives a total of 1,114,820 weekly downloads. As such, babel-plugin-transform-es2015-parameters popularity was classified as popular.
We found that babel-plugin-transform-es2015-parameters 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.