npm install periscopic
99.1
Supply Chain Risk
89.2
Quality
75.7
Maintenance
100
Vulnerability
89 Stars
74 Commits
7 Forks
4 Watching
1 Branches
6 Contributors
Updated on 18 Aug 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
0.9%
363,531
Compared to previous day
Last week
7%
1,933,809
Compared to previous week
Last month
12.1%
8,009,853
Compared to previous month
Last year
154%
69,706,349
Compared to previous year
3
4
Utility for analyzing scopes belonging to an ESTree-compliant AST.
import { analyze } from 'periscopic'; const ast = acorn.parse(` const a = b; console.log(a); `); const { map, globals, scope } = analyze(ast);
map
is a WeakMap<Node, Scope>
, where the keys are the nodes of your AST that create a scopeglobals
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 programEach Scope
instance has the following properties:
scope.block
— true if the scope is created by a block statement (i.e. let
, const
and class
are contained to it), false otherwisescope.parent
— the parent scope objectscope.declarations
— a Map<string, Node>
of all the variables declared in this scope, the node value referes to the declaration statementscope.initialised_declarations
— a Set<string>
of all the variables declared and initialised in this scopescope.references
— a Set<string>
of all the names referenced in this scope (or child scopes)It also has two methods:
scope.has(name)
— returns true
if name
is declared in this scope or an ancestor scopescope.find_owner(name)
— returns the scope object in which name
is declared (or null
if it is not declared)extract_identifiers
and extract_names
This package also exposes utilities for extracting the identifiers contained in a declaration or a function parameter:
import { extract_identifiers, extract_names } from 'periscopic'; const ast = acorn.parse(` const { a, b: [c, d] = e } = opts; `); const lhs = ast.body[0].declarations[0].id; extract_identifiers(lhs); /* [ { type: 'Identifier', name: 'a', start: 9, end: 10 }, { type: 'Identifier', name: 'c', start: 16, end: 17 }, { type: 'Identifier', name: 'd', start: 19, end: 20 } ] */ extract_names(lhs); /* ['a', 'c', 'd'] */
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
Found 5/15 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Score
Last Scanned on 2024-09-09
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More