new Path(items, recursionKey, tree, item)
Path class for navigating recursive data arrays.
Parameters:
| Name |
Type |
Description |
items |
Array.<Object>
|
An array of items. |
recursionKey |
String
|
The object key which points to the child items array. Separate object keys with a dot "." to denote a deeper level. |
tree |
Array.<string>
|
The tree path of the current item. |
item |
Object
|
Current item. |
Properties:
| Name |
Type |
Description |
items |
Array
|
The array containing all the items. |
recursionKey |
String
|
The object key that points to the child items. |
item |
Object
|
The current item. |
children |
Array
|
The child items of the current item. |
tree |
Array
|
The tree path of the current item. |
index |
Number
|
The index of the current item. |
startTree |
Array
|
The start tree of the path. |
Methods
child() → {Path}
Navigates to the child item with the specified index.
Returns:
The current Path instance.
-
Type
-
Path
create() → {Path}
Creates a new Path object instance with the current tree position.
Returns:
-
Type
-
Path
first() → {Path}
Navigates to the first item on the current level.
Returns:
The current Path instance.
-
Type
-
Path
firstChild() → {Path}
Navigates to the first child item.
Returns:
The current Path instance.
-
Type
-
Path
hasNext() → {Boolean}
Checks if we can move to a next item from the current index in the active list.
Returns:
A value indicating if there is a next item.
-
Type
-
Boolean
hasParent() → {Boolean}
Checks if the current item has a parent item.
Returns:
A value indicating if the current item has a parent item.
-
Type
-
Boolean
hasPrevious() → {Boolean}
Checks if we can move to a previous item from the current index in the active list.
Returns:
A value indicating if there is a previous item.
-
Type
-
Boolean
last() → {Path}
Navigates to the last item on the current level.
Returns:
The current Path instance.
-
Type
-
Path
lastChild() → {Path}
Navigates to the last child item.
Returns:
The current Path instance.
-
Type
-
Path
length() → {Number}
Returns the length of the items array at the current level.
Returns:
The length of the items array.
-
Type
-
Number
next() → {Path}
Navigates to the next item on the current level.
Returns:
The current Path instance.
-
Type
-
Path
parent() → {Path}
Navigates to the parent item.
Returns:
The current Path instance.
-
Type
-
Path
path(comparer, scalar) → {Path}
Iterates through the items in the array and evaluates each object against the specified comparer function.
The iteration is called recursively when the recursionKey is found on an object.
Parameters:
| Name |
Type |
Description |
comparer |
function
|
The comparer method. |
scalar |
boolean
|
A value indicating if only the first path is returned. |
Returns:
A new instance of the Path object.
-
Type
-
Path
previous() → {Path}
Navigates to the previous item on the current level.
Returns:
The current Path instance.
-
Type
-
Path
root() → {Path}
Navigates to the root item.
Returns:
The current Path instance.
-
Type
-
Path
sibling() → {Path}
Navigates to the item with the specified index on the current level.
Returns:
The current Path instance.
-
Type
-
Path
start() → {Path}
Navigates to the starting item.
Returns:
The current Path instance.
-
Type
-
Path