Socket
Socket
Sign inDemoInstall

@babel/helper-wrap-function

Package Overview
Dependencies
4
Maintainers
4
Versions
82
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.18.9 to 7.18.10

38

lib/index.js

@@ -19,2 +19,3 @@ "use strict";

isAssignmentPattern,
isFunctionDeclaration,
isRestElement,

@@ -62,19 +63,18 @@ returnStatement

function plainFunction(path, callId, noNewArrows, ignoreFunctionLength) {
const node = path.node;
const isDeclaration = path.isFunctionDeclaration();
const functionId = node.id;
const wrapper = isDeclaration ? buildDeclarationWrapper : functionId ? buildNamedExpressionWrapper : buildAnonymousExpressionWrapper;
let functionId = null;
let node;
if (path.isArrowFunctionExpression()) {
path.arrowFunctionToExpression({
path = path.arrowFunctionToExpression({
noNewArrows
});
node = path.node;
} else {
node = path.node;
}
const isDeclaration = isFunctionDeclaration(node);
functionId = node.id;
node.id = null;
if (isDeclaration) {
node.type = "FunctionExpression";
}
node.type = "FunctionExpression";
const built = callExpression(callId, [node]);

@@ -91,3 +91,3 @@ const params = [];

const container = wrapper({
const wrapperArgs = {
NAME: functionId || null,

@@ -97,19 +97,25 @@ REF: path.scope.generateUidIdentifier(functionId ? functionId.name : "ref"),

PARAMS: params
});
};
if (isDeclaration) {
const container = buildDeclarationWrapper(wrapperArgs);
path.replaceWith(container[0]);
path.insertAfter(container[1]);
} else {
const retFunction = container.callee.body.body[1].argument;
let container;
if (!functionId) {
if (functionId) {
container = buildNamedExpressionWrapper(wrapperArgs);
} else {
container = buildAnonymousExpressionWrapper(wrapperArgs);
const returnFn = container.callee.body.body[1].argument;
(0, _helperFunctionName.default)({
node: retFunction,
node: returnFn,
parent: path.parent,
scope: path.scope
});
functionId = returnFn.id;
}
if (!retFunction || retFunction.id || !ignoreFunctionLength && params.length) {
if (functionId || !ignoreFunctionLength && params.length) {
path.replaceWith(container);

@@ -116,0 +122,0 @@ } else {

{
"name": "@babel/helper-wrap-function",
"version": "7.18.9",
"version": "7.18.10",
"description": "Helper to wrap functions inside a function call.",

@@ -18,5 +18,5 @@ "repository": {

"@babel/helper-function-name": "^7.18.9",
"@babel/template": "^7.18.6",
"@babel/traverse": "^7.18.9",
"@babel/types": "^7.18.9"
"@babel/template": "^7.18.10",
"@babel/traverse": "^7.18.10",
"@babel/types": "^7.18.10"
},

@@ -23,0 +23,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc