# ast-parents

> Walks a JavaScript AST and adds a "parent" property to each node

Latest version **0.0.1** (published 2014-02-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install ast-parents
pnpm add ast-parents
yarn add ast-parents
bun add ast-parents
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2014-02-04 |
| First published | 2014-02-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | ast, walk, parents, node, syntax, parse |

## Links

- npm: https://www.npmjs.com/package/ast-parents
- Repository: https://github.com/hughsk/ast-parents
- Issues: https://github.com/hughsk/ast-parents/issues
- npm.io page: https://npm.io/package/ast-parents

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2014-02-04
- 0.0.0 — 2014-02-04

## README

# ast-parents [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/ast-parents&title=ast-parents&description=hughsk/ast-parents%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #

Walks a JavaScript AST, such as one supplied via
[esprima](http://github.com/ariya/esprima), and adds a `parent`
property to each node.

Makes it much easier to navigate the AST, and the `parent` properties
added here are non-enumerable so you can still serialize the tree to JSON
without `JSON.stringify` throwing an error.

## Usage ##

[![ast-parents](https://nodei.co/npm/ast-parents.png?mini=true)](https://nodei.co/npm/ast-parents)

`require('ast-parents')(ast)`

Where `ast` is an AST object. For example:

``` javascript
var esprima = require('esprima')
var fs = require('fs')

var src = fs.readFileSync(__filename, 'utf8')
var ast = esprima.parse(src)

parents(ast)

ast.body[0].parent === ast.body
```

## License ##

MIT. See [LICENSE.md](http://github.com/hughsk/ast-parents/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/ast-parents · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
