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

acorn-globals

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acorn-globals

Detect global variables in JavaScript using acorn

  • 4.3.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is acorn-globals?

The acorn-globals npm package is used to extract global variables from JavaScript code. It leverages the Acorn JS parser to analyze scripts and identify global variables, which can be useful for various applications such as linting tools, code analysis, and optimization tools.

What are acorn-globals's main functionalities?

Extracting global variables

This feature allows you to parse JavaScript code and extract a list of global variables used in the code. The example shows how to parse a simple script and identify 'console' as a global variable.

const acornGlobals = require('acorn-globals');
const acorn = require('acorn');

const code = 'console.log("Hello, world!");';
const ast = acorn.parse(code, {ecmaVersion: 2020});
const globals = acornGlobals(ast);

console.log(globals);

Other packages similar to acorn-globals

Keywords

FAQs

Package last updated on 12 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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