https://github.com/goto-bus-stop/undeclared-identifiers
find undeclared identifiers and property accesses in a javascript file.
https://github.com/goto-bus-stop/undeclared-identifiers
Last synced: 2 months ago
JSON representation
find undeclared identifiers and property accesses in a javascript file.
- Host: GitHub
- URL: https://github.com/goto-bus-stop/undeclared-identifiers
- Owner: goto-bus-stop
- License: other
- Created: 2018-03-10T10:21:50.000Z (over 7 years ago)
- Default Branch: default
- Last Pushed: 2022-08-26T16:12:56.000Z (almost 3 years ago)
- Last Synced: 2025-03-29T03:06:10.884Z (3 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/undeclared-identifiers
- Size: 27.3 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# undeclared-identifiers
find undeclared identifiers and property accesses in a javascript file.
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url][npm-image]: https://img.shields.io/npm/v/undeclared-identifiers.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/undeclared-identifiers
[travis-image]: https://img.shields.io/travis/goto-bus-stop/undeclared-identifiers.svg?style=flat-square
[travis-url]: https://travis-ci.org/goto-bus-stop/undeclared-identifiers
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard## Install
```
npm install undeclared-identifiers
```## Usage
```js
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](https://github.com/browserify/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.*'`.
```js
undeclaredIdentifiers('Buffer(), Buffer.from()', { wildcard: true })
// { identifiers: ['Buffer'],
// properties: ['Buffer.*', 'Buffer.from'] }
```## License
[Apache-2.0](LICENSE.md)