New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

javascript-idents

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

javascript-idents

Walks a JavaScript AST and collects Identifier nodes

0.0.1
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

javascript-idents

javascript-idents walks a JavaScript AST and collects all Identifier AST nodes. It relies on Marijn Haverbeke's acorn.js for AST walking, and it should be compatible with any SpiderMonkey Parser API-compliant JavaScript AST.

It is intended for use in node.js but can be adapted to work in other JavaScript environments.

Documentation: javascript-idents on Sourcegraph

Example

The following example prints the name of each Identifier AST node to the console.

var acorn = require('acorn'), idents = require('javascript-idents');

var src = 'var c = a.b[d]; function f(w, x, y) { return z; }';
var astNode = acorn.parse(src);
idents.inspect(astNode, function(ident) {
  console.log('Ident:', ident.name);
});

// output:
// Ident: c
// Ident: a
// Ident: b
// Ident: d
// Ident: f
// Ident: w
// Ident: x
// Ident: y
// Ident: z

Running tests

Run npm test.

Contributors

  • Quinn Slack sqs@sourcegraph.com

FAQs

Package last updated on 27 Aug 2013

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