Socket
Socket
Sign inDemoInstall

ast-parents

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ast-parents

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


Version published
Weekly downloads
60K
increased by1.47%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

ast-parents Flattr this!experimental

Walks a JavaScript AST, such as one supplied via 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

require('ast-parents')(ast)

Where ast is an AST object. For example:

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 for details.

Keywords

FAQs

Last updated on 04 Feb 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc