Socket
Socket
Sign inDemoInstall

@babel/traverse

Package Overview
Dependencies
Maintainers
4
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/traverse - npm Package Compare versions

Comparing version 7.25.6 to 7.25.7

2

lib/path/context.js

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

const denylist = (_this$opts$denylist = this.opts.denylist) != null ? _this$opts$denylist : this.opts.blacklist;
return denylist && denylist.indexOf(this.node.type) > -1;
return denylist == null ? void 0 : denylist.includes(this.node.type);
}

@@ -67,0 +67,0 @@ {

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

for (const [, path] of paths) {
if (typeof path.key === "number" && path.key >= fromIndex) {
if (typeof path.key === "number" && path.container === this.container && path.key >= fromIndex) {
path.key += incrementBy;

@@ -169,0 +169,0 @@ }

@@ -293,4 +293,4 @@ "use strict";

this.block = void 0;
this.inited = void 0;
this.labels = void 0;
this.inited = void 0;
this.bindings = void 0;

@@ -329,11 +329,2 @@ this.references = void 0;

}
get parentBlock() {
return this.path.parent;
}
get hub() {
return this.path.hub;
}
traverse(node, opts, state) {
(0, _index.default)(node, opts, this, state, this.path);
}
generateDeclaredUidIdentifier(name) {

@@ -354,3 +345,4 @@ const id = this.generateUidIdentifier(name);

do {
uid = this._generateUid(name, i);
uid = `_${name}`;
if (i > 1) uid += i;
i++;

@@ -363,7 +355,2 @@ } while (this.hasLabel(uid) || this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid));

}
_generateUid(name, i) {
let id = name;
if (i > 1) id += i;
return `_${id}`;
}
generateUidBasedOnNode(node, defaultName) {

@@ -412,3 +399,3 @@ const parts = [];

if (duplicate) {
throw this.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
throw this.path.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
}

@@ -426,8 +413,2 @@ }

}
_renameFromMap(map, oldName, newName, value) {
if (map[oldName]) {
map[newName] = value;
map[oldName] = null;
}
}
dump() {

@@ -451,33 +432,2 @@ const sep = "-".repeat(60);

}
toArray(node, i, arrayLikeIsIterable) {
if (isIdentifier(node)) {
const binding = this.getBinding(node.name);
if (binding != null && binding.constant && binding.path.isGenericType("Array")) {
return node;
}
}
if (isArrayExpression(node)) {
return node;
}
if (isIdentifier(node, {
name: "arguments"
})) {
return callExpression(memberExpression(memberExpression(memberExpression(identifier("Array"), identifier("prototype")), identifier("slice")), identifier("call")), [node]);
}
let helperName;
const args = [node];
if (i === true) {
helperName = "toConsumableArray";
} else if (typeof i === "number") {
args.push(numericLiteral(i));
helperName = "slicedToArray";
} else {
helperName = "toArray";
}
if (arrayLikeIsIterable) {
args.unshift(this.hub.addHelper(helperName));
helperName = "maybeArrayLike";
}
return callExpression(this.hub.addHelper(helperName), args);
}
hasLabel(name) {

@@ -822,16 +772,2 @@ return !!this.getLabel(name);

}
getAllBindingsOfKind(...kinds) {
const ids = Object.create(null);
for (const kind of kinds) {
let scope = this;
do {
for (const name of Object.keys(scope.bindings)) {
const binding = scope.bindings[name];
if (binding.kind === kind) ids[name] = binding;
}
scope = scope.parent;
} while (scope);
}
return ids;
}
bindingIdentifierEquals(name, node) {

@@ -969,3 +905,80 @@ return this.getBindingIdentifier(name) === node;

Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"];
{
Scope.prototype._renameFromMap = function _renameFromMap(map, oldName, newName, value) {
if (map[oldName]) {
map[newName] = value;
map[oldName] = null;
}
};
Scope.prototype.traverse = function (node, opts, state) {
(0, _index.default)(node, opts, this, state, this.path);
};
Scope.prototype._generateUid = function _generateUid(name, i) {
let id = name;
if (i > 1) id += i;
return `_${id}`;
};
Scope.prototype.toArray = function toArray(node, i, arrayLikeIsIterable) {
if (isIdentifier(node)) {
const binding = this.getBinding(node.name);
if (binding != null && binding.constant && binding.path.isGenericType("Array")) {
return node;
}
}
if (isArrayExpression(node)) {
return node;
}
if (isIdentifier(node, {
name: "arguments"
})) {
return callExpression(memberExpression(memberExpression(memberExpression(identifier("Array"), identifier("prototype")), identifier("slice")), identifier("call")), [node]);
}
let helperName;
const args = [node];
if (i === true) {
helperName = "toConsumableArray";
} else if (typeof i === "number") {
args.push(numericLiteral(i));
helperName = "slicedToArray";
} else {
helperName = "toArray";
}
if (arrayLikeIsIterable) {
args.unshift(this.path.hub.addHelper(helperName));
helperName = "maybeArrayLike";
}
return callExpression(this.path.hub.addHelper(helperName), args);
};
Scope.prototype.getAllBindingsOfKind = function getAllBindingsOfKind(...kinds) {
const ids = Object.create(null);
for (const kind of kinds) {
let scope = this;
do {
for (const name of Object.keys(scope.bindings)) {
const binding = scope.bindings[name];
if (binding.kind === kind) ids[name] = binding;
}
scope = scope.parent;
} while (scope);
}
return ids;
};
Object.defineProperties(Scope.prototype, {
parentBlock: {
configurable: true,
enumerable: true,
get() {
return this.path.parent;
}
},
hub: {
configurable: true,
enumerable: true,
get() {
return this.path.hub;
}
}
});
}
//# sourceMappingURL=index.js.map

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

if (!TYPES.includes(nodeType)) {
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"7.25.6"}`);
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"7.25.7"}`);
}

@@ -110,0 +110,0 @@ const visitors = visitor[nodeType];

{
"name": "@babel/traverse",
"version": "7.25.6",
"version": "7.25.7",
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",

@@ -19,7 +19,7 @@ "author": "The Babel Team (https://babel.dev/team)",

"dependencies": {
"@babel/code-frame": "^7.24.7",
"@babel/generator": "^7.25.6",
"@babel/parser": "^7.25.6",
"@babel/template": "^7.25.0",
"@babel/types": "^7.25.6",
"@babel/code-frame": "^7.25.7",
"@babel/generator": "^7.25.7",
"@babel/parser": "^7.25.7",
"@babel/template": "^7.25.7",
"@babel/types": "^7.25.7",
"debug": "^4.3.1",

@@ -29,4 +29,4 @@ "globals": "^11.1.0"

"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/helper-plugin-test-runner": "^7.24.7"
"@babel/core": "^7.25.7",
"@babel/helper-plugin-test-runner": "^7.25.7"
},

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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