Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goto-bus-stop/estree-assign-parent
assign `.parent` properties to all nodes in an ast.
https://github.com/goto-bus-stop/estree-assign-parent
ancestors ast estree javascript parent
Last synced: 27 days ago
JSON representation
assign `.parent` properties to all nodes in an ast.
- Host: GitHub
- URL: https://github.com/goto-bus-stop/estree-assign-parent
- Owner: goto-bus-stop
- License: other
- Created: 2017-11-21T18:37:02.000Z (almost 7 years ago)
- Default Branch: default
- Last Pushed: 2023-05-31T04:59:06.000Z (over 1 year ago)
- Last Synced: 2024-10-05T16:26:08.140Z (about 1 month ago)
- Topics: ancestors, ast, estree, javascript, parent
- Language: JavaScript
- Size: 14.6 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# estree-assign-parent
assign `.parent` properties to all nodes in an ast.
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url][npm-image]: https://img.shields.io/npm/v/estree-assign-parent.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/estree-assign-parent
[travis-image]: https://img.shields.io/travis/goto-bus-stop/estree-assign-parent.svg?style=flat-square
[travis-url]: https://travis-ci.org/goto-bus-stop/estree-assign-parent
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard## Install
```
npm install estree-assign-parent
```## Usage
```js
var assignParent = require('estree-assign-parent')var ast = assignParent(parse(`
module.exports = function xyz () {
return xyz.toString()
}
`))assert.equal(ast.body[0].parent, ast)
```## API
### `assignParent(ast, key='parent')`
Add a `parent` key to all nodes belonging to `ast`, referring to the parent node.
The `key` option can be used to assign a different name, like `'parentNode'`.## License
[Apache-2.0](LICENSE.md)