Gathering detailed insights and metrics for @ltd/acorn-globals
Gathering detailed insights and metrics for @ltd/acorn-globals
Gathering detailed insights and metrics for @ltd/acorn-globals
Gathering detailed insights and metrics for @ltd/acorn-globals
npm install @ltd/acorn-globals
Typescript
Module System
Node Version
NPM Version
71.5
Supply Chain
90.2
Quality
75.8
Maintenance
100
Vulnerability
81.3
License
TypeScript (93.35%)
JavaScript (6.65%)
Total Downloads
3,503
Last Day
2
Last Week
3
Last Month
49
Last Year
294
19 Commits
2 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
3.0.0
Package Id
@ltd/acorn-globals@3.0.0
Unpacked Size
32.29 kB
Size
8.20 kB
File Count
5
NPM Version
6.14.15
Node Version
14.17.6
Cumulative downloads
Total Downloads
Last day
100%
2
Compared to previous day
Last week
-81.3%
3
Compared to previous week
Last month
1,533.3%
49
Compared to previous month
Last year
-57.3%
294
Compared to previous year
1
@ltd/acorn-globals
This package is adapted from acorn-globals
.
When I found improvable things in use, I submitted some PR for to improve it together.
But there's one thing I think it's not a defect, but a requirement for most people, but not for me, so I can only publish a modified package.
The major difference is that acorn-globals
automatically ignores references to global variable undefined
, while @ltd/acorn-globals
reserves it to decide in user land.
At the same time, if the input is not a Program
node whose sourceType
is not module
, the variable names declared at top-level will also be included in the output.
License: From MIT
to LGPL-3.0
, almost same unlimited for using, while the difference is that if the package itself is modified, it must be released as open source with the same license.
Host Requirement: Because it is a back-end package, it uses ES 6+ feature.
Reduce the API: The the main export function only accepts the parsed AST
object as argument, not the code
string and options
arguments, and no parse
method exported.
Because users may use different versions and grammar plug-ins with different options
in different cases, I don't want too much coupling.
Parameter Read-Only: No modification of AST
argument (acorn-globals
modified the locals
and parents
properties of nodes).
Return Value: The return value is changed from { name :string, nodes :Node[] }[]
to Map<string, Node[]> & { names (): string[], nodes () :Node[] }
.
1const find = require('@ltd/acorn-globals'); 2const AST = require('acorn')/*.Parser.extend(plugin)*/.parse(code/*, options*/); 3const globals = find(AST); 4console.log(globals.names());
这个包改编自 acorn-globals
。
我在使用中发现可以改进的地方时,都第一时间提交了 PR 以共同完善。
但是其中有一处我认为是它的功能而非缺陷,也是多数人的需求,但不是我的需求,因而只能单独发布一个修改后的包。
这个最重要的差异就是,acorn-globals
会自动忽略对于全局变量 undefined
的引用,而 @ltd/acorn-globals
会保留,供用户自行取舍。
同时,如果传入的不是 sourceType
属性为 "module"
的 Program
节点,那么顶层声明的变量名也会列入全局名录。
许可协议:从 MIT
变为 LGPL-3.0
,使用上一样,几乎就是没限制,主要区别是如果对包本身进行了改造,则必须以同样许可协议开源发布。
宿主要求:由于是后端用包,使用了 ES 6 以上的特性。
缩小接口:模块主导出函数只接受解析后的 AST
对象作为参数,而不接受 code
字符串和 options
,同时取消导出 parse
方法函数,以尽可能解除耦合,满足用户对不同 acorn
版本、语法插件、options
的需求。
参数只读:不对 AST
参数作修改(acorn-globals
中修改了节点的 locals
和 parents
属性)。
返回形式:返回值从 { name :string, nodes :Node[] }[]
改为 Map<string, Node[]> & { names () :string[], nodes () :Node[] }
。
1const find = require('@ltd/acorn-globals'); 2const AST = require('acorn')/*.Parser.extend(plugin)*/.parse(code/*, options*/); 3const globals = find(AST); 4console.log(globals.names());
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/19 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-27
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