estree-assign-parent

assign `.parent` properties to all nodes in an ast.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
estree-assign-parent
321.0.05 years ago5 years agoMinified + gzip package size for estree-assign-parent in KB

Readme

estree-assign-parent
assign .parent properties to all nodes in an ast.
!npmnpm-imagenpm-url !travistravis-imagetravis-url !standardstandard-imagestandard-url

Install

npm install estree-assign-parent

Usage

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