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.19.0 to 7.20.5

46

lib/index.js

@@ -7,9 +7,5 @@ "use strict";

exports.default = wrapFunction;
var _helperFunctionName = require("@babel/helper-function-name");
var _template = require("@babel/template");
var _t = require("@babel/types");
const {

@@ -22,5 +18,5 @@ blockStatement,

isRestElement,
returnStatement
returnStatement,
isCallExpression
} = _t;
const buildAnonymousExpressionWrapper = _template.default.expression(`

@@ -34,3 +30,2 @@ (function () {

`);
const buildNamedExpressionWrapper = _template.default.expression(`

@@ -45,3 +40,2 @@ (function () {

`);
const buildDeclarationWrapper = _template.default.statements(`

@@ -54,3 +48,2 @@ function NAME(PARAMS) { return REF.apply(this, arguments); }

`);
function classOrObjectMethod(path, callId) {

@@ -61,15 +54,16 @@ const node = path.node;

body.body = [returnStatement(callExpression(callExpression(callId, [container]), []))];
node.async = false;
node.generator = false;
path.get("body.body.0.argument.callee.arguments.0").unwrapFunctionEnvironment();
}
function plainFunction(path, callId, noNewArrows, ignoreFunctionLength) {
function plainFunction(inPath, callId, noNewArrows, ignoreFunctionLength) {
let path = inPath;
let node;
let functionId = null;
let node;
const nodeParams = inPath.node.params;
if (path.isArrowFunctionExpression()) {
{
var _path$arrowFunctionTo;
path = (_path$arrowFunctionTo = path.arrowFunctionToExpression({

@@ -83,18 +77,17 @@ noNewArrows

}
const isDeclaration = isFunctionDeclaration(node);
functionId = node.id;
node.id = null;
node.type = "FunctionExpression";
const built = callExpression(callId, [node]);
let built = node;
if (!isCallExpression(node)) {
functionId = node.id;
node.id = null;
node.type = "FunctionExpression";
built = callExpression(callId, [node]);
}
const params = [];
for (const param of node.params) {
for (const param of nodeParams) {
if (isAssignmentPattern(param) || isRestElement(param)) {
break;
}
params.push(path.scope.generateUidIdentifier("x"));
}
const wrapperArgs = {

@@ -106,3 +99,2 @@ NAME: functionId || null,

};
if (isDeclaration) {

@@ -114,3 +106,2 @@ const container = buildDeclarationWrapper(wrapperArgs);

let container;
if (functionId) {

@@ -128,3 +119,2 @@ container = buildNamedExpressionWrapper(wrapperArgs);

}
if (functionId || !ignoreFunctionLength && params.length) {

@@ -137,4 +127,4 @@ path.replaceWith(container);

}
function wrapFunction(path, callId, noNewArrows = true, ignoreFunctionLength = false) {
function wrapFunction(path, callId,
noNewArrows = true, ignoreFunctionLength = false) {
if (path.isMethod()) {

@@ -141,0 +131,0 @@ classOrObjectMethod(path, callId);

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

@@ -19,4 +19,4 @@ "repository": {

"@babel/template": "^7.18.10",
"@babel/traverse": "^7.19.0",
"@babel/types": "^7.19.0"
"@babel/traverse": "^7.20.5",
"@babel/types": "^7.20.5"
},

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

Sorry, the diff of this file is not supported yet

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