Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

periscopic

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

periscopic - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

6

CHANGELOG.md
# periscopic changelog
## 2.0.0
* Match API used by Svelte's internal helpers ([#4](https://github.com/Rich-Harris/periscopic/pull/4))
* Change `globals` to a `Map<string, Node>`
* Change value of `scope.declarations` to the variable declaration, not declarator
## 1.1.0

@@ -4,0 +10,0 @@

26

dist/periscopic.js

@@ -21,3 +21,3 @@ 'use strict';

});
} else if (/Function/.test(node.type)) {
} else if (/(Function(Declaration|Expression)|ArrowFunctionExpression)/.test(node.type)) {
if (node.type === 'FunctionDeclaration') {

@@ -28,3 +28,3 @@ scope.declarations.set(node.id.name, node);

map.set(node, scope = new Scope(scope, false));
if (node.id) scope.declarations.set(node.id.name, node);
if (node.type === 'FunctionExpression' && node.id) scope.declarations.set(node.id.name, node);
}

@@ -61,2 +61,5 @@

const globals = new Map();
const root_scope = scope;
estreeWalker.walk(expression, {

@@ -67,3 +70,7 @@ enter(node, parent) {

if (node.type === 'Identifier' && is_reference(node, parent)) {
add_reference(scope, node.name);
if (add_reference(scope, node.name) === root_scope) {
if (!root_scope.declarations.has(node.name)) {
globals.set(node.name, node);
}
}
}

@@ -78,10 +85,2 @@ },

const globals = new Set();
scope.references.forEach(name => {
if (!scope.declarations.has(name)) {
globals.add(name);
}
});
return { map, scope, globals };

@@ -92,3 +91,4 @@ }

scope.references.add(name);
if (scope.parent && !scope.declarations.has(name)) add_reference(scope.parent, name);
if (scope.parent && !scope.declarations.has(name)) return add_reference(scope.parent, name);
return scope;
}

@@ -116,3 +116,3 @@

extract_names(declarator.id).forEach(name => {
this.declarations.set(name, declarator);
this.declarations.set(name, node);
if (declarator.init) this.initialised_declarations.add(name);

@@ -119,0 +119,0 @@ });

{
"name": "periscopic",
"description": "periscopic",
"version": "1.1.0",
"version": "2.0.0",
"repository": "Rich-Harris/periscopic",

@@ -6,0 +6,0 @@ "main": "dist/periscopic.js",

@@ -20,3 +20,3 @@ # periscopic

* `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`)
* `globals` is a `Map<string, Node>` of all the identifiers that are referenced without being declared anywhere in the program (in this case, `b` and `console`)
* `scope` is the top-level `Scope` belonging to the program

@@ -31,3 +31,4 @@

* `scope.parent` — the parent scope object
* `scope.declarations` — a `Map<string, Node>` of all the variables declared in this scope
* `scope.declarations` — a `Map<string, Node>` of all the variables declared in this scope, the node value referes to the declaration statement
* `scope.initialised_declarations` — a `Set<string>` of all the variables declared and initialised in this scope
* `scope.references` — a `Set<string>` of all the names referenced in this scope (or child scopes)

@@ -34,0 +35,0 @@

@@ -5,3 +5,3 @@ import { Node, VariableDeclaration, ClassDeclaration, Identifier } from 'estree';

scope: Scope;
globals: Set<string>;
globals: Map<string, Node>;
};

@@ -8,0 +8,0 @@ export declare class Scope {

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