You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
3 years ago | |
---|---|---|
.. | ||
test | 3 years ago | |
.travis.yml | 3 years ago | |
CHANGELOG.md | 3 years ago | |
LICENSE.md | 3 years ago | |
README.md | 3 years ago | |
index.js | 3 years ago | |
package.json | 3 years ago |
README.md
get-assigned-identifiers
get a list of identifiers that are initialised by a JavaScript AST node.
Install
npm install get-assigned-identifiers
Usage
var getAssignedIdentifiers = require('get-assigned-identifiers')
var ast = parse(`
var { a, b: [ c,, ...x ], d } = whatever()
`)
var node = ast.body[0].declarations[0].id
getAssignedIdentifiers(node)
// → [{ name: 'a' }, { name: 'c' }, { name: 'x' }, { name: 'd' }]
API
getAssignedIdentifiers(node)
Return an array of AST Nodes referencing identifiers that are initialised by the node
, taking into account destructuring.
If node
is not an identifier or destructuring node, this returns an empty array.