Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inDemoInstall

acorn-globals

Package Overview
Dependencies
2
Maintainers
3
Versions
27
Issues
File Explorer

Advanced tools

acorn-globals

Detect global variables in JavaScript using acorn

    7.0.1latest
    Github

Version published
Maintainers
3
Weekly downloads
15,092,269
decreased by-18.22%

Weekly downloads

Changelog

Source

7.0.1

Bug Fixes

  • The body of switch statement is a block scope (#67)

    In this example:

    switch (3) { case 3: let a; } a; // this 'a' is a global

    The a at the bottom is global, even though a variable called a was declared inside the switch statement.

Readme

Source

acorn-globals

Detect global variables in JavaScript using acorn

Get supported acorn-globals with the Tidelift Subscription

Build Status Rolling Versions NPM version

Installation

npm install acorn-globals

Usage

detect.js

var fs = require('fs'); var detect = require('acorn-globals'); var src = fs.readFileSync(__dirname + '/input.js', 'utf8'); var scope = detect(src); console.dir(scope);

input.js

var x = 5; var y = 3, z = 2; w.foo(); w = 2; RAWR=444; RAWR.foo(); BLARG=3; foo(function () { var BAR = 3; process.nextTick(function (ZZZZZZZZZZZZ) { console.log('beep boop'); var xyz = 4; x += 10; x.zzzzzz; ZZZ=6; }); function doom () { } ZZZ.foo(); }); console.log(xyz);

output:

$ node example/detect.js [ { name: 'BLARG', nodes: [ [Object] ] }, { name: 'RAWR', nodes: [ [Object], [Object] ] }, { name: 'ZZZ', nodes: [ [Object], [Object] ] }, { name: 'console', nodes: [ [Object], [Object] ] }, { name: 'foo', nodes: [ [Object] ] }, { name: 'process', nodes: [ [Object] ] }, { name: 'w', nodes: [ [Object], [Object] ] }, { name: 'xyz', nodes: [ [Object] ] } ]

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

License

MIT

Keywords

FAQs

What is acorn-globals?

Detect global variables in JavaScript using acorn

Is acorn-globals popular?

The npm package acorn-globals receives a total of 12,023,991 weekly downloads. As such, acorn-globals popularity was classified as popular.

Is acorn-globals well maintained?

We found that acorn-globals demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 3 open source maintainers collaborating on the project.

Last updated on 02 Sep 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket[email protected]

Product

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc