NodeWrapper

NodeWrapper

Wrap an AST node to get some basic helpers / parent reference

Constructor

new NodeWrapper(node, parentopt)

Create a new NodeWrapper

Parameters:
Name Type Attributes Description
node object
parent NodeWrapper <optional>
Source:

Members

children :Array.<NodeWrapper>

Type:
Source:

node :object

Type:
  • object
Source:

parent :NodeWrapper

Type:
Source:

Methods

(static) create(node, parentopt) → {NodeWrapper}

Create a new NodeWrapper or return the argument if it's already a NodeWrapper

Parameters:
Name Type Attributes Description
node object | NodeWrapper
parent NodeWrapper <optional>
Source:
Returns:
Type
NodeWrapper

(static) isNodeWrapper(node) → {NodeWrapper}

Return true if the provided argument is a NodeWrapper

Parameters:
Name Type Description
node any
Source:
Returns:
Type
NodeWrapper

reduce(fn, acc) → {object}

Recursivley reduce the node and it's children

Parameters:
Name Type Description
fn function
acc any
Source:
Returns:
Type
object

toJSON() → {object}

Return the JSON representation

Source:
Returns:
Type
object