@babel/traverse
Advanced tools
Comparing version 7.20.8 to 7.20.10
@@ -163,3 +163,3 @@ "use strict"; | ||
function getOuterFunction(path) { | ||
return (path.parentPath.scope.getFunctionParent() || path.parentPath.scope.getProgramParent()).path; | ||
return path.isProgram() ? path : (path.parentPath.scope.getFunctionParent() || path.parentPath.scope.getProgramParent()).path; | ||
} | ||
@@ -212,2 +212,4 @@ function isExecutionUncertain(type, key) { | ||
const SYMBOL_CHECKING = Symbol(); | ||
function _guessExecutionStatusRelativeTo(target) { | ||
@@ -269,7 +271,5 @@ return _guessExecutionStatusRelativeToCached(this, target, new Map()); | ||
} | ||
const executionOrderCheckedNodes = new Set(); | ||
function _guessExecutionStatusRelativeToDifferentFunctionsInternal(base, target, cache) { | ||
if (!target.isFunctionDeclaration()) { | ||
if (base._guessExecutionStatusRelativeTo(target) === "before") { | ||
if (_guessExecutionStatusRelativeToCached(base, target, cache) === "before") { | ||
return "before"; | ||
@@ -294,14 +294,7 @@ } | ||
} | ||
if (executionOrderCheckedNodes.has(path.node)) continue; | ||
executionOrderCheckedNodes.add(path.node); | ||
try { | ||
const status = _guessExecutionStatusRelativeToCached(base, path, cache); | ||
if (allStatus && allStatus !== status) { | ||
return "unknown"; | ||
} else { | ||
allStatus = status; | ||
} | ||
} finally { | ||
executionOrderCheckedNodes.delete(path.node); | ||
const status = _guessExecutionStatusRelativeToCached(base, path, cache); | ||
if (allStatus && allStatus !== status) { | ||
return "unknown"; | ||
} else { | ||
allStatus = status; | ||
} | ||
@@ -313,7 +306,12 @@ } | ||
let nodeMap = cache.get(base.node); | ||
let cached; | ||
if (!nodeMap) { | ||
cache.set(base.node, nodeMap = new Map()); | ||
} else if (nodeMap.has(target.node)) { | ||
return nodeMap.get(target.node); | ||
} else if (cached = nodeMap.get(target.node)) { | ||
if (cached === SYMBOL_CHECKING) { | ||
return "unknown"; | ||
} | ||
return cached; | ||
} | ||
nodeMap.set(target.node, SYMBOL_CHECKING); | ||
const result = _guessExecutionStatusRelativeToDifferentFunctionsInternal(base, target, cache); | ||
@@ -320,0 +318,0 @@ nodeMap.set(target.node, result); |
{ | ||
"name": "@babel/traverse", | ||
"version": "7.20.8", | ||
"version": "7.20.10", | ||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes", | ||
@@ -5,0 +5,0 @@ "author": "The Babel Team (https://babel.dev/team)", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
577311
5074