armansansd 3424b1927b first commit il y a 2 ans
..
bench 3424b1927b first commit il y a 2 ans
test 3424b1927b first commit il y a 2 ans
.travis.yml 3424b1927b first commit il y a 2 ans
CHANGELOG.md 3424b1927b first commit il y a 2 ans
LICENSE.md 3424b1927b first commit il y a 2 ans
README.md 3424b1927b first commit il y a 2 ans
bin.js 3424b1927b first commit il y a 2 ans
index.js 3424b1927b first commit il y a 2 ans
package.json 3424b1927b first commit il y a 2 ans

README.md

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