npm install rogain-tree-utilsUtilities for manipulating and traversing Rogain trees.
Splits an array of trees at matching tree.
___treeList___
Array of trees.
___match___
Object.
match is used to segment the input array between each matching tree.
``js
var branches = splitTree(tree.children, {
type: 'helper',
name: 'Else'
});
var passing = branches[0];
var failing = branches[1];
`
__note__ will return an array of tree branches in the format [ [ trees ], [ trees ] ] even on a single tree result like, [ [ tree ] ]
Finds the first tree matching the match object in treeList.
___treeList___
Array of trees. Haystack of trees.
___match___
Object. Needle tree.
`js`
var res = find(tree.children, { type: 'helper', name: 'Else' });
Finds all trees matching the match object in treeList.
___treeList___
Array of trees. Haystack of trees.
___match___
Object. Needle tree.
`js`
var res = findAll(tree.children, { type: 'tag', tagName: 'a' });
Predicate, returns true when tree has children.
___tree___
Tree.
`js`
if (hasChildren(tree)) {
// do children stuff
}
With npm do:
```
npm install rogain-tree-utils
MIT