sensordb2 e64a8defe5 3.17 | 1 rok pred | |
---|---|---|
.. | ||
bench | 1 rok pred | |
test | 1 rok pred | |
.travis.yml | 1 rok pred | |
CHANGELOG.md | 1 rok pred | |
LICENSE.md | 1 rok pred | |
README.md | 1 rok pred | |
bin.js | 1 rok pred | |
index.js | 1 rok pred | |
package.json | 1 rok pred |
find undeclared identifiers and property accesses in a javascript file.
npm install undeclared-identifiers
var undeclaredIdentifiers = require('undeclared-identifiers')
undeclaredIdentifiers(src)
// { identifiers: ['Buffer'],
// properties: ['Buffer.isBuffer'] }
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'] }