You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@babel/traverse

Package Overview
Dependencies
Maintainers
4
Versions
212
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.26.10
to
7.27.0
+8
-16
lib/index.js

@@ -73,21 +73,13 @@ "use strict";

};
function hasDenylistedType(path, state) {
if (path.node.type === state.type) {
state.has = true;
path.stop();
}
}
traverse.hasType = function (tree, type, denylistTypes) {
if (denylistTypes != null && denylistTypes.includes(tree.type)) return false;
if (tree.type === type) return true;
const state = {
has: false,
type: type
};
traverse(tree, {
noScope: true,
denylist: denylistTypes,
enter: hasDenylistedType
}, null, state);
return state.has;
return traverseFast(tree, function (node) {
if (denylistTypes != null && denylistTypes.includes(node.type)) {
return traverseFast.skip;
}
if (node.type === type) {
return traverseFast.stop;
}
});
};

@@ -94,0 +86,0 @@ traverse.cache = cache;

@@ -133,5 +133,3 @@ "use strict";

while (path) {
for (const type of candidateTypes) {
if (path.node.type === type) return true;
}
if (candidateTypes.includes(path.node.type)) return true;
path = path.parentPath;

@@ -138,0 +136,0 @@ }

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

this.kind = kind;
if ((kind === "var" || kind === "hoisted") && isDeclaredInLoop(path)) {
if ((kind === "var" || kind === "hoisted") && isInitInLoop(path)) {
this.reassign(path);

@@ -68,3 +68,4 @@ }

exports.default = Binding;
function isDeclaredInLoop(path) {
function isInitInLoop(path) {
const isFunctionDeclarationOrHasInit = !path.isVariableDeclarator() || path.node.init;
for (let {

@@ -78,3 +79,3 @@ parentPath,

if (parentPath.isFunctionParent()) return false;
if (parentPath.isWhile() || parentPath.isForXStatement() || parentPath.isForStatement() && key === "body") {
if (key === "left" && parentPath.isForXStatement() || isFunctionDeclarationOrHasInit && key === "body" && parentPath.isLoop()) {
return true;

@@ -81,0 +82,0 @@ }

@@ -14,5 +14,3 @@ "use strict";

var _cache = require("../cache.js");
var _visitors = require("../visitors.js");
const {
NOT_LOCAL_BINDING,
assignmentExpression,

@@ -182,2 +180,11 @@ callExpression,

}
function resetScope(scope) {
scope.references = Object.create(null);
scope.bindings = Object.create(null);
scope.globals = Object.create(null);
scope.uids = Object.create(null);
}
{
var NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding");
}
const collectorVisitor = {

@@ -297,2 +304,3 @@ ForStatement(path) {

};
let scopeVisitor;
let uid = 0;

@@ -641,6 +649,3 @@ class Scope {

const path = this.path;
this.references = Object.create(null);
this.bindings = Object.create(null);
this.globals = Object.create(null);
this.uids = Object.create(null);
resetScope(this);
this.data = Object.create(null);

@@ -661,7 +666,12 @@ let scope = this;

this.crawling = true;
if (path.type !== "Program" && (0, _visitors.isExplodedVisitor)(collectorVisitor)) {
for (const visit of collectorVisitor.enter) {
scopeVisitor || (scopeVisitor = _index.default.visitors.merge([{
Scope(path) {
resetScope(path.scope);
}
}, collectorVisitor]));
if (path.type !== "Program") {
for (const visit of scopeVisitor.enter) {
visit.call(state, path, state);
}
const typeVisitors = collectorVisitor[path.type];
const typeVisitors = scopeVisitor[path.type];
if (typeVisitors) {

@@ -673,3 +683,3 @@ for (const visit of typeVisitors.enter) {

}
path.traverse(collectorVisitor, state);
path.traverse(scopeVisitor, state);
this.crawling = false;

@@ -820,16 +830,21 @@ for (const path of state.assignments) {

if (!name) return false;
let scope = this;
do {
if (scope.hasOwnBinding(name)) {
return true;
}
} while (scope = scope.parent);
let noGlobals;
let noUids;
let upToScope;
if (typeof opts === "object") {
noGlobals = opts.noGlobals;
noUids = opts.noUids;
upToScope = opts.upToScope;
} else if (typeof opts === "boolean") {
noGlobals = opts;
}
let scope = this;
do {
if (upToScope === scope) {
break;
}
if (scope.hasOwnBinding(name)) {
return true;
}
} while (scope = scope.parent);
if (!noUids && this.hasUid(name)) return true;

@@ -836,0 +851,0 @@ if (!noGlobals && Scope.globals.includes(name)) return true;

@@ -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.26.10"}`);
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"7.27.0"}`);
}

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

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

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

"@babel/code-frame": "^7.26.2",
"@babel/generator": "^7.26.10",
"@babel/parser": "^7.26.10",
"@babel/template": "^7.26.9",
"@babel/types": "^7.26.10",
"@babel/generator": "^7.27.0",
"@babel/parser": "^7.27.0",
"@babel/template": "^7.27.0",
"@babel/types": "^7.27.0",
"debug": "^4.3.1",

@@ -26,0 +26,0 @@ "globals": "^11.1.0"

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet