periscopic
Advanced tools
Comparing version 1.0.0 to 1.0.1
# periscopic changelog | ||
## 1.0.1 | ||
* Only attach scope-creating nodes to the scope map | ||
## 1.0.0 | ||
* First release |
@@ -15,4 +15,2 @@ 'use strict'; | ||
let stack = []; | ||
estreeWalker.walk(expression, { | ||
@@ -27,5 +25,5 @@ enter(node, parent) { | ||
scope.declarations.set(node.id.name, node); | ||
scope = new Scope(scope, false); | ||
map.set(node, scope = new Scope(scope, false)); | ||
} else { | ||
scope = new Scope(scope, false); | ||
map.set(node, scope = new Scope(scope, false)); | ||
if (node.id) scope.declarations.set(node.id.name, node); | ||
@@ -40,9 +38,9 @@ } | ||
} else if (/For(?:In|Of)?Statement/.test(node.type)) { | ||
scope = new Scope(scope, true); | ||
map.set(node, scope = new Scope(scope, true)); | ||
} else if (node.type === 'BlockStatement') { | ||
scope = new Scope(scope, true); | ||
map.set(node, scope = new Scope(scope, true)); | ||
} else if (/(Class|Variable)Declaration/.test(node.type)) { | ||
add_declaration(scope, node); | ||
} else if (node.type === 'CatchClause') { | ||
scope = new Scope(scope, true); | ||
map.set(node, scope = new Scope(scope, true)); | ||
@@ -55,9 +53,8 @@ extract_names(node.param).forEach(name => { | ||
} | ||
map.set(node, scope); | ||
stack.push(scope); | ||
}, | ||
leave(node) { | ||
scope = stack.pop(); | ||
if (map.has(node)) { | ||
scope = scope.parent; | ||
} | ||
} | ||
@@ -64,0 +61,0 @@ }); |
{ | ||
"name": "periscopic", | ||
"description": "periscopic", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"repository": "Rich-Harris/periscopic", | ||
@@ -34,4 +34,4 @@ "main": "dist/periscopic.js", | ||
"dependencies": { | ||
"is-reference": "^1.1.3" | ||
"is-reference": "^1.1.4" | ||
} | ||
} |
@@ -19,3 +19,3 @@ # periscopic | ||
* `map` is a `WeakMap<Node, Scope>`, where the keys are the nodes of your AST | ||
* `map` is a `WeakMap<Node, Scope>`, where the keys are the nodes of your AST that create a scope | ||
* `globals` is a `Set<string>` of all the identifiers that are referenced without being declared anywhere in the program (in this case, `b` and `console`) | ||
@@ -22,0 +22,0 @@ * `scope` is the top-level `Scope` belonging to the program |
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
12387
274
Updatedis-reference@^1.1.4