Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-parameters

Package Overview
Dependencies
Maintainers
4
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-transform-parameters - npm Package Compare versions

Comparing version 7.17.12 to 7.18.6

19

lib/params.js

@@ -10,3 +10,3 @@ "use strict";

const buildDefaultParam = (0, _core.template)(`
const buildDefaultParam = _core.template.statement(`
let VARIABLE_NAME =

@@ -18,3 +18,4 @@ arguments.length > ARGUMENT_KEY && arguments[ARGUMENT_KEY] !== undefined ?

`);
const buildLooseDefaultParam = (0, _core.template)(`
const buildLooseDefaultParam = _core.template.statement(`
if (ASSIGNMENT_IDENTIFIER === UNDEFINED) {

@@ -24,8 +25,11 @@ ASSIGNMENT_IDENTIFIER = DEFAULT_VALUE;

`);
const buildLooseDestructuredDefaultParam = (0, _core.template)(`
const buildLooseDestructuredDefaultParam = _core.template.statement(`
let ASSIGNMENT_IDENTIFIER = PARAMETER_NAME === UNDEFINED ? DEFAULT_VALUE : PARAMETER_NAME ;
`);
const buildSafeArgumentsAccess = (0, _core.template)(`
const buildSafeArgumentsAccess = _core.template.statement(`
let $0 = arguments.length > $1 ? arguments[$1] : undefined;
`);
const iifeVisitor = {

@@ -120,3 +124,3 @@ "ReferencedIdentifier|BindingIdentifier"(path, state) {

if (replaceRestElement) {
replaceRestElement(param.parentPath, param, transformedRestNodes);
replaceRestElement(path, param, transformedRestNodes);
}

@@ -126,3 +130,5 @@

if (paramIsAssignmentPattern && (ignoreFunctionLength || node.kind === "set")) {
if (paramIsAssignmentPattern && (ignoreFunctionLength || _core.types.isMethod(node, {
kind: "set"
}))) {
const left = param.get("left");

@@ -164,2 +170,3 @@ const right = param.get("right");

const uid = path.scope.generateUidIdentifier("ref");
uid.typeAnnotation = param.node.typeAnnotation;

@@ -166,0 +173,0 @@ const defNode = _core.types.variableDeclaration("let", [_core.types.variableDeclarator(param.node, uid)]);

@@ -10,3 +10,3 @@ "use strict";

const buildRest = (0, _core.template)(`
const buildRest = _core.template.statement(`
for (var LEN = ARGUMENTS.length,

@@ -20,9 +20,12 @@ ARRAY = new Array(ARRAY_LEN),

`);
const restIndex = (0, _core.template)(`
const restIndex = _core.template.expression(`
(INDEX < OFFSET || ARGUMENTS.length <= INDEX) ? undefined : ARGUMENTS[INDEX]
`);
const restIndexImpure = (0, _core.template)(`
const restIndexImpure = _core.template.expression(`
REF = INDEX, (REF < OFFSET || ARGUMENTS.length <= REF) ? undefined : ARGUMENTS[REF]
`);
const restLength = (0, _core.template)(`
const restLength = _core.template.expression(`
ARGUMENTS.length <= OFFSET ? 0 : ARGUMENTS.length - OFFSET

@@ -153,13 +156,15 @@ `);

let index;
const parent = path.parent;
if (_core.types.isNumericLiteral(path.parent.property)) {
index = _core.types.numericLiteral(path.parent.property.value + offset);
if (_core.types.isNumericLiteral(parent.property)) {
index = _core.types.numericLiteral(parent.property.value + offset);
} else if (offset === 0) {
index = path.parent.property;
index = parent.property;
} else {
index = _core.types.binaryExpression("+", path.parent.property, _core.types.cloneNode(offsetLiteral));
index = _core.types.binaryExpression("+", parent.property, _core.types.cloneNode(offsetLiteral));
}
const {
scope
scope,
parentPath
} = path;

@@ -173,3 +178,3 @@

});
path.parentPath.replaceWith(restIndexImpure({
parentPath.replaceWith(restIndexImpure({
ARGUMENTS: argsId,

@@ -181,3 +186,2 @@ OFFSET: offsetLiteral,

} else {
const parentPath = path.parentPath;
parentPath.replaceWith(restIndex({

@@ -188,10 +192,11 @@ ARGUMENTS: argsId,

}));
const offsetTestPath = parentPath.get("test").get("left");
const valRes = offsetTestPath.evaluate();
const replacedParentPath = parentPath;
const offsetTestPath = replacedParentPath.get("test");
const valRes = offsetTestPath.get("left").evaluate();
if (valRes.confident) {
if (valRes.value === true) {
parentPath.replaceWith(parentPath.scope.buildUndefinedNode());
replacedParentPath.replaceWith(scope.buildUndefinedNode());
} else {
parentPath.get("test").replaceWith(parentPath.get("test").get("right"));
offsetTestPath.replaceWith(offsetTestPath.get("right"));
}

@@ -220,6 +225,3 @@ }

let rest = node.params.pop().argument;
if (rest.name === "arguments") scope.rename(rest.name);
const argsId = _core.types.identifier("arguments");
if (_core.types.isPattern(rest)) {

@@ -231,5 +233,10 @@ const pattern = rest;

path.ensureBlock();
node.body.body.unshift(declar);
} else if (rest.name === "arguments") {
scope.rename(rest.name);
}
const argsId = _core.types.identifier("arguments");
const paramsCount = getParamsCount(node);

@@ -236,0 +243,0 @@ const state = {

{
"name": "@babel/plugin-transform-parameters",
"version": "7.17.12",
"version": "7.18.6",
"description": "Compile ES2015 default and rest parameters to ES5",

@@ -17,3 +17,3 @@ "repository": {

"dependencies": {
"@babel/helper-plugin-utils": "^7.17.12"
"@babel/helper-plugin-utils": "^7.18.6"
},

@@ -27,4 +27,4 @@ "keywords": [

"devDependencies": {
"@babel/core": "^7.17.12",
"@babel/helper-plugin-test-runner": "^7.16.7"
"@babel/core": "^7.18.6",
"@babel/helper-plugin-test-runner": "^7.18.6"
},

@@ -34,3 +34,4 @@ "engines": {

},
"author": "The Babel Team (https://babel.dev/team)"
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
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