package
Syntax Tree
npm install syntax-treeGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
$ npm install --save syntax-treevar SyntaxTree = require( 'syntax-tree' )// Create a new tree
var tree = new SyntaxTree()
// Create a new node
var childNode = new SyntaxTree.Node({
type: 'ArbitraryNode'
})
// Add nodes to the tree
tree.root.appendChild( childNode )
tree.root.prependChild( otherChildNode )
// Replace a node
someNode.replaceChild( oldChild, newChild )
// Insertions
someNode.insertBefore( newChild, existingChild )
someNode.insertAfter( newChild, existingChild )
// Removals
someNode.removeChild( child )
otherNode.remove()
// Siblings
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;
};interface Data {};interface Root <: Node {
type: "Root";
parent: Root;
};