Syntax Tree
npm
Install via$ npm install --save syntax-tree
Usage
var SyntaxTree =
// Create a new treevar tree = // Create a new nodevar childNode = type: 'ArbitraryNode' // Add nodes to the treetreeroottreeroot // Replace a nodesomeNode // InsertionssomeNodesomeNode // RemovalssomeNodeotherNode // SiblingssomeNodenextSiblingsomeNodepreviousSibling // ChildrensomeNodefirstChild // -> child|nullsomeNodelastChild // -> child|null // RelationshipssomeNodeisParent // -> true|falsesomeNodeisChild // -> true|false
Interface Definition
Node
interface Node { readonly attribute isRoot: boolean; readonly attribute isParent: boolean; readonly attribute isChild: boolean; readonly attribute firstChild: Child | null; readonly attribute lastChild: Child | null; readonly attribute previousSibling: Node | null; readonly attribute nextSibling: Node | null; type: String; parent: Node?; children: [ Child ]; data: Data | null; };
Data
interface Data {};
Root
interface Root <: Node { type: "Root"; parent: Root;};