symbol-tree
Example
const SymbolTree = require('symbol-tree');
const tree = new SymbolTree();
let a = {foo: 'bar'}; // or `new Whatever()`
let b = {foo: 'baz'};
let c = {foo: 'qux'};
tree.insertBefore(b, a); // insert a before b
tree.insertAfter(b, c); // insert c after b
console.log(tree.nextSibling(a) === b);
console.log(tree.nextSibling(b) === c);
console.log(tree.previousSibling(c) === b);
tree.remove(b);
console.log(tree.nextSibling(a) === c);Testing
API Documentation
symbol-tree
SymbolTree ⏏
new SymbolTree([description])
Param
Type
Default
Description
symbolTree.initialize(object) ⇒ Object
ObjectParam
Type
symbolTree.hasChildren(object) ⇒ Boolean
BooleanParam
Type
symbolTree.firstChild(object) ⇒ Object
ObjectParam
Type
symbolTree.lastChild(object) ⇒ Object
ObjectParam
Type
symbolTree.previousSibling(object) ⇒ Object
ObjectParam
Type
symbolTree.nextSibling(object) ⇒ Object
ObjectParam
Type
symbolTree.parent(object) ⇒ Object
ObjectParam
Type
symbolTree.lastInclusiveDescendant(object) ⇒ Object
ObjectParam
Type
symbolTree.preceding(object, [options]) ⇒ Object
ObjectParam
Type
Description
symbolTree.following(object, [options]) ⇒ Object
ObjectParam
Type
Default
Description
symbolTree.childrenToArray(parent, [options]) ⇒ Array.<Object>
Array.<Object>Param
Type
Default
Description
symbolTree.ancestorsToArray(object, [options]) ⇒ Array.<Object>
Array.<Object>Param
Type
Default
Description
symbolTree.treeToArray(root, [options]) ⇒ Array.<Object>
Array.<Object>Param
Type
Default
Description
symbolTree.childrenIterator(parent, [options]) ⇒ Object
ObjectParam
Type
Default
symbolTree.previousSiblingsIterator(object) ⇒ Object
ObjectParam
Type
symbolTree.nextSiblingsIterator(object) ⇒ Object
ObjectParam
Type
symbolTree.ancestorsIterator(object) ⇒ Object
ObjectParam
Type
symbolTree.treeIterator(root, options) ⇒ Object
ObjectParam
Type
Default
symbolTree.index(child) ⇒ Number
NumberParam
Type
symbolTree.childrenCount(parent) ⇒ Number
NumberParam
Type
symbolTree.compareTreePosition(left, right) ⇒ Number
NumberParam
Type
symbolTree.remove(removeObject) ⇒ Object
ObjectParam
Type
symbolTree.insertBefore(referenceObject, newObject) ⇒ Object
ObjectParam
Type
symbolTree.insertAfter(referenceObject, newObject) ⇒ Object
ObjectParam
Type
symbolTree.prependChild(referenceObject, newObject) ⇒ Object
ObjectParam
Type
symbolTree.appendChild(referenceObject, newObject) ⇒ Object
ObjectParam
Type
Last updated