开发者社区> 镜像站> NPM> undeclared-identifiers
undeclared-identifiers
find undeclared identifiers and property accesses in a javascript file.
Last updated 2 years ago by goto-bus-stop .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install undeclared-identifiers 
SYNC missed versions from official npm registry.

undeclared-identifiers

find undeclared identifiers and property accesses in a javascript file.

npm travis standard

Install

npm install undeclared-identifiers

Usage

var undeclaredIdentifiers = require('undeclared-identifiers')

undeclaredIdentifiers(src)
// { identifiers: ['Buffer'],
//   properties: ['Buffer.isBuffer'] }

API

res = undeclaredIdentifiers(source, opts)

Find undeclared identifiers and properties that are used in the source. source can be an AST or a source string that will be parsed using acorn-node.

res is an object with properties:

  • res.identifiers - an array of variable names as strings.
  • res.properties - an array of property names as .-separated strings, such as 'xyz.abc'. These are the property accesses on the undeclared variables found in res.identifiers.

Set opts.properties to false to only return identifiers.

When opts.wildcard is true, unknown uses of undeclared identifiers will be added to res.properties as 'VarName.*'.

undeclaredIdentifiers('Buffer(), Buffer.from()', { wildcard: true })
// { identifiers: ['Buffer'],
//   properties: ['Buffer.*', 'Buffer.from'] }

License

Apache-2.0

Current Tags

  • 1.1.3                                ...           latest (2 years ago)

5 Versions

  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 8
This Week 2,111
This Month 1,599
Last Day 603
Last Week 3,080
Last Month 12,699
Dependencies (5)
Dev Dependencies (7)