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 3.1.0 to 4.0.0

types/index.d.ts.map

14

package.json
{
"name": "periscopic",
"description": "periscopic",
"version": "3.1.0",
"version": "4.0.0",
"repository": "Rich-Harris/periscopic",

@@ -11,3 +11,3 @@ "main": "src/index.js",

"types": "./types/index.js",
"import": "./src/index.js"
"default": "./src/index.js"
},

@@ -21,2 +21,3 @@ "types": "types/index.d.ts",

"acorn": "^8.0.0",
"dts-buddy": "^0.2.4",
"typescript": "^4.9.0",

@@ -27,3 +28,3 @@ "uvu": "^0.5.1"

"test": "uvu test",
"prepublishOnly": "npm test && tsc"
"prepublishOnly": "npm test && dts-buddy"
},

@@ -33,5 +34,6 @@ "license": "MIT",

"@types/estree": "^1.0.0",
"estree-walker": "^3.0.0",
"is-reference": "^3.0.0"
}
"is-reference": "^3.0.0",
"zimmerframe": "^1.0.0"
},
"packageManager": "pnpm@8.7.4"
}

@@ -1,2 +0,2 @@

import { walk } from 'estree-walker';
import { walk } from 'zimmerframe';
import is_reference from 'is-reference';

@@ -18,19 +18,35 @@

const references = [];
/** @type {Scope} */
let current_scope = scope;
walk(expression, {
enter(node, parent) {
/**
* @param {import('estree').Node} node
* @param {boolean} block
*/
function push(node, block) {
map.set(node, (current_scope = new Scope(current_scope, block)));
}
walk(/** @type {import('estree').Node} */ (expression), null, {
_(node, context) {
switch (node.type) {
case 'Identifier':
const parent = context.path.at(-1);
if (parent && is_reference(node, parent)) {
references.push([current_scope, node]);
}
break;
return;
case 'ImportDeclaration':
node.specifiers.forEach((specifier) => {
current_scope.declarations.set(specifier.local.name, specifier);
});
break;
case 'ImportSpecifier':
current_scope.declarations.set(node.local.name, specifier);
return;
case 'ExportNamedDeclaration':
if (node.source) {
map.set(node, (current_scope = new Scope(current_scope, true)));
node.specifiers.forEach((specifier) => {
current_scope.declarations.set(specifier.local.name, specifier);
});
return;
}

@@ -45,5 +61,5 @@ case 'FunctionExpression':

map.set(node, current_scope = new Scope(current_scope, false));
push(node, false);
} else {
map.set(node, current_scope = new Scope(current_scope, false));
push(node, false);

@@ -55,4 +71,4 @@ if (node.type === 'FunctionExpression' && node.id) {

node.params.forEach(param => {
extract_names(param).forEach(name => {
node.params.forEach((param) => {
extract_names(param).forEach((name) => {
current_scope.declarations.set(name, node);

@@ -66,7 +82,5 @@ });

case 'ForOfStatement':
map.set(node, current_scope = new Scope(current_scope, true));
break;
case 'BlockStatement':
map.set(node, current_scope = new Scope(current_scope, true));
case 'SwitchStatement':
push(node, true);
break;

@@ -80,6 +94,6 @@

case 'CatchClause':
map.set(node, current_scope = new Scope(current_scope, true));
push(node, true);
if (node.param) {
extract_names(node.param).forEach(name => {
extract_names(node.param).forEach((name) => {
if (node.param) {

@@ -92,5 +106,5 @@ current_scope.declarations.set(name, node.param);

}
},
leave(node) {
context.next();
if (map.has(node) && current_scope !== null && current_scope.parent) {

@@ -127,4 +141,4 @@ current_scope = current_scope.parent;

/**
* @param {Scope | null} parent
* @param {boolean} block
* @param {Scope | null} parent
* @param {boolean} block
*/

@@ -158,7 +172,7 @@ constructor(parent, block) {

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

@@ -197,3 +211,3 @@ node.declarations.forEach(handle_declarator);

export function extract_names(param) {
return extract_identifiers(param).map(node => node.name);
return extract_identifiers(param).map((node) => node.name);
}

@@ -241,3 +255,3 @@

if (element) {
handle_element(element)
handle_element(element);
}

@@ -244,0 +258,0 @@ });

@@ -1,48 +0,33 @@

/** @param {import('estree').Node} expression */
export function analyze(expression: import('estree').Node): {
map: WeakMap<import("estree").Node, Scope>;
scope: Scope;
globals: Map<string, import("estree").Node>;
};
/**
* @param {import('estree').Node} param
* @returns {string[]}
*/
export function extract_names(param: import('estree').Node): string[];
/**
* @param {import('estree').Node} param
* @param {import('estree').Identifier[]} nodes
* @returns {import('estree').Identifier[]}
*/
export function extract_identifiers(param: import('estree').Node, nodes?: import('estree').Identifier[]): import('estree').Identifier[];
export class Scope {
/**
* @param {Scope | null} parent
* @param {boolean} block
*/
constructor(parent: Scope | null, block: boolean);
/** @type {Scope | null} */
parent: Scope | null;
/** @type {boolean} */
block: boolean;
/** @type {Map<string, import('estree').Node>} */
declarations: Map<string, import('estree').Node>;
/** @type {Set<string>} */
initialised_declarations: Set<string>;
/** @type {Set<string>} */
references: Set<string>;
/**
* @param {import('estree').VariableDeclaration | import('estree').ClassDeclaration} node
*/
add_declaration(node: import('estree').VariableDeclaration | import('estree').ClassDeclaration): void;
/**
* @param {string} name
* @returns {Scope | null}
*/
find_owner(name: string): Scope | null;
/**
* @param {string} name
* @returns {boolean}
*/
has(name: string): boolean;
declare module 'periscopic' {
export function analyze(expression: import('estree').Node): {
map: WeakMap<import("estree").Node, Scope>;
scope: Scope;
globals: Map<string, import("estree").Node>;
};
export function extract_names(param: import('estree').Node): string[];
export function extract_identifiers(param: import('estree').Node, nodes?: import('estree').Identifier[]): import('estree').Identifier[];
export class Scope {
constructor(parent: Scope | null, block: boolean);
parent: Scope | null;
block: boolean;
declarations: Map<string, import('estree').Node>;
initialised_declarations: Set<string>;
references: Set<string>;
add_declaration(node: import('estree').VariableDeclaration | import('estree').ClassDeclaration): void;
find_owner(name: string): Scope | null;
has(name: string): boolean;
}
}
//# sourceMappingURL=index.d.ts.map
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