new Node()
- Source:
Members
(static) Indent :Number
The indent level of the given node.
- Source:
Type:
- Number
(static) NextNode :Node
The next node of the given node.
- Source:
Type:
(static) Owner :Object
The owner data object of the given node.
- Source:
Type:
- Object
(static) PrevNode :Node
The previous node of the given node.
- Source:
Type:
Methods
(static) AddChild(ChildItemopt, ChildIndexopt) → (non-null) {Object}
Adds a new item as a child of this node.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
ChildItem |
Object |
<optional> |
Object
|
The child object to add. |
ChildIndex |
number |
<optional> |
-1
|
The index at which to add the child. Use -1 to append. |
Returns:
The newly added child item.
- Type
- Object
(static) AddChildren(ChildItems) → {Array}
Adds an array of data objects as children to this node.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
ChildItems |
Array | The array of data objects to add. |
Returns:
The Items array passed in.
- Type
- Array
(static) Child(ChildIndex) → {Object}
Gets an item by its child index.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
ChildIndex |
Number | The index of the child to find. |
Returns:
The child item at ChildIndex or null if not found.
- Type
- Object
(static) ChildCount() → {Number}
Gets the count of immediate child items.
- Source:
Returns:
The number of immediate child items.
- Type
- Number
(static) Children() → {Array}
Gets an array of the immediate child items.
- Source:
Returns:
Array of the immediate child items.
- Type
- Array
(static) Descendant(DescendantIndex) → {Object}
Gets an item by its descendant index.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
DescendantIndex |
Number | The index of the descendant to find. |
Returns:
The descendant item at DescendantIndex or null if not found.
- Type
- Object
(static) DescendantCount() → {Number}
Gets the count of descendant items.
- Source:
Returns:
The number of descendant items.
- Type
- Number
(static) Descendants() → {Array}
Gets an array of the descendant items.
- Source:
Returns:
Array of the descendant items.
- Type
- Array
(static) FindFirstChildNode()
Find the first child of this node.
- Source:
(static) FindFirstDescendantNode()
Find the first descendant of this node. This will always be the same as FindFirstChild().
- Source:
(static) FindFirstNode()
Find the first node in the hierarchy.
- Source:
(static) FindFirstSiblingNode()
Find the first sibling of this node.
- Source:
(static) FindLastChildNode()
Find the last child of this node.
- Source:
(static) FindLastDescendantNode()
Find the last descendant of this node.
- Source:
(static) FindLastNode()
Find the last node in the hierarchy.
- Source:
(static) FindLastSiblingNode()
Find the last sibling of this node.
- Source:
(static) FindNextNode()
Find the next node in the hierarchy.
- Source:
(static) FindNextSiblingNode()
Find the next sibling of this node.
- Source:
(static) FindParentNode()
Find the parent of this node.
- Source:
(static) FindPath(TextPath, TextProperty, IncludeThisopt, Delimiteropt) → (nullable) {Object}
Locates a node given a text path string.
- Source:
Given a text path to a node (e.g. /A1/B1/C2), this function will return that node.
The TextPath parameter is a string and is similar to strings returned by the TextPath function.
The Delimiter parameter separates the elements of the path within TextPath.
If Delimiter is empty, ThisNode will be returned.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
TextPath |
string | The path of the node to return. |
||
TextProperty |
string | The name of the property containing the path elements. |
||
IncludeThis |
boolean |
<optional> |
false
|
The path includes the |
Delimiter |
string |
<optional> |
'/'
|
The character(s) used to delimit the path elements. |
Returns:
The located node, or null if not found.
- Type
- Object
(static) FindPrevNode()
Find the previous node in the hierarchy.
- Source:
(static) FindPrevSiblingNode()
Find the previous sibling of this node.
- Source:
(static) FindRelative(RelationshipType) → (nullable) {Object}
Finds a single other node within the hierarchy of a specific relation to the given node.
- Source:
The RelationshipType parameter must be one of:
PrevNode : Finds the immediately previous node.
NextNode : Finds the immediately next node.
FirstNode : Finds the very first node. This will also always be the root node.
LastNode : Finds the very last node.
RootNode : Finds the root node.
ParentNode : Finds the parent node.
PrevSibNode : Finds the previous sibling node.
NextSibNode : Finds the next sibling node.
FirstSibNode : Finds the first sibling node.
LastSibNode : Finds the last sibling node.
FirstChildNode : Finds the first child node.
LastChildNode : Finds the last child node.
FirstDescNode : Finds the first descendant node.
LastDescNode : Finds the last descendant node.
D3 = C2.Prev A1 C3 = C2.Next +- B1 A1 = C1.First | +- C1 C7 = C1.Last | | +- D1 A1 = C1.Root | | +- D2 B1 = C1.Parent | | +- D3 C1 = C2.PrevSib | +- C2 C2 = C1.NextSib | +- C3 C1 = C1.FirstSib +- B2 C3 = C1.LastSib | +- C4 B1 = A1.FirstChild | +- C5 B3 = A1.LastChild | +- C6 B1 = A1.FirstDesc +- B3 C7 = A1.LastDesc +- C7
Parameters:
| Name | Type | Description |
|---|---|---|
RelationshipType |
RelationshipTypes | The type of node to look for. |
Returns:
The item found by the RelationshipType, or null if not found.
- Type
- Object
(static) FindRootNode()
Find the root node of the hierarchy.
- Source:
(static) RemoveChild(ChildIndex) → (nullable) {Object}
Removes a child node of this node.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
ChildIndex |
number | The index of the child to remove. |
Returns:
The removed child item.
- Type
- Object
(static) RemoveChildren() → {Array}
Removes all child nodes from this node.
- Source:
Returns:
Array of the removed child items.
- Type
- Array
(static) TextGraph(TextProperty, IncludeThisopt, IndentTextopt, EolTextopt) → {string}
Renders a graph of the hierarchy using text characters.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
TextProperty |
string | The property to use for the node in the graph (e.g. it's name or other text value). |
||
IncludeThis |
boolean |
<optional> |
false
|
Include the root in the output. |
IndentText |
string |
<optional> |
'\t'
|
The characters to use to indent each node. |
EolText |
string |
<optional> |
'\n'
|
The characters to use after each node. |
Returns:
The text graph as a string.
- Type
- string
(static) TextPath(TextProperty, IncludeRootopt, Delimiteropt) → {string}
Retrieves the text path of a node.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
TextProperty |
string | The name of the property containing the path elements. |
||
IncludeRoot |
boolean |
<optional> |
true
|
The root node will be included in the path. |
Delimiter |
string |
<optional> |
'/'
|
The character(s) used to delimit the path elements. |
Returns:
The text path of the node.
- Type
- string
(static) VisitAllNodes(Visitornon-null)
Invoke Visitor on all the nodes.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
Visitor |
function | The function to invoke on each node visited. See |
(static) VisitChildNodes(Visitornon-null, IncludeThisopt, nullable)
Invoke Visitor on child nodes.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Visitor |
function | The function to invoke on each node visited. See |
||
IncludeThis |
boolean |
<optional> <nullable> |
false
|
This node will be included and visited first. |
(static) VisitDescendantNodes(Visitornon-null, IncludeThisopt, nullable)
Invoke Visitor on descendant nodes.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Visitor |
function | The function to invoke on each node visited. See |
||
IncludeThis |
boolean |
<optional> <nullable> |
false
|
This node will be included and visited first. |
(static) VisitNextNodes(Visitornon-null, IncludeThisopt, nullable)
Invoke Visitor on next nodes.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Visitor |
function | The function to invoke on each node visited. See |
||
IncludeThis |
boolean |
<optional> <nullable> |
false
|
This node will be included and visited first. |
(static) VisitNextSibNodes(Visitornon-null, IncludeThisopt, nullable)
Invoke Visitor on next sibling nodes.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Visitor |
function | The function to invoke on each node visited. See |
||
IncludeThis |
boolean |
<optional> <nullable> |
false
|
This node will be included and visited first. |
(static) VisitNodes(VisitationType, Visitornon-null, IncludeThisopt, nullable) → {boolean}
Visits every one of a class of nodes defined by VisitationType.
- Source:
The VisitationType parameter must be one of:
AllNodes : Visit all node in the hierarchy (depth-first).
PrevNodes : Visits all the nodes previous to this one (backwards).
NextNodes : Visits all the nodes after this one (forewards).
ParentNodes : Visits all the parents of this node (upwards).
SiblingNodes : Visits all the siblings of this node (sideways).
PrevSibNodes : Visits all the siblings previous to this one.
NextSibNodes : Visits all the siblings after this one.
ChildNodes : Visits all the child nodes of this one. (downwards)
DecendantNodes : Visits all the descendant nodes of this one. (downwards)
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
VisitationType |
VisitationTypes | Identifies which nodes to visit. |
||
Visitor |
function | The function to invoke on each node visited.
If the Visitor returns a value, the visitation process
is aborted and |
||
IncludeThis |
boolean |
<optional> <nullable> |
false
|
This node will be included and visited first. |
Returns:
Any return value from Visitor, otherwise undefined.
- Type
- boolean
(static) VisitParentNodes(Visitornon-null, IncludeThisopt, nullable)
Invoke Visitor on parent nodes.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Visitor |
function | The function to invoke on each node visited. See |
||
IncludeThis |
boolean |
<optional> <nullable> |
false
|
This node will be included and visited first. |
(static) VisitPrevNodes(Visitornon-null, IncludeThisopt, nullable)
Invoke Visitor on previous nodes.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Visitor |
function | The function to invoke on each node visited. See |
||
IncludeThis |
boolean |
<optional> <nullable> |
false
|
This node will be included and visited first. |
(static) VisitPrevSibNodes(Visitornon-null, IncludeThisopt, nullable)
Invoke Visitor on previous sibling nodes.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Visitor |
function | The function to invoke on each node visited. See |
||
IncludeThis |
boolean |
<optional> <nullable> |
false
|
This node will be included and visited first. |
(static) VisitSiblingNodes(Visitornon-null, IncludeThisopt, nullable)
Invoke Visitor on sibling nodes.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Visitor |
function | The function to invoke on each node visited. See |
||
IncludeThis |
boolean |
<optional> <nullable> |
false
|
This node will be included and visited first. |