Methods
addToSet(set, value)
Treats a given array as a set and adds a value only if
the value doesn't exist in the array.
Parameters:
Name | Type | Description |
---|---|---|
set |
Array | Set to modify |
value |
* | Value to add to the set. |
- Source:
allToSet(set, values)
Adds all values to a set.
Parameters:
Name | Type | Description |
---|---|---|
set |
Array | Set to modify. |
values |
Array | Values to add to the set. |
- Source:
- See:
traverse(helper) → {TreeTraversal}
Factory method for creating new tree traversals.
This is the only method exposed via the exports.
Parameters:
Name | Type | Description |
---|---|---|
helper |
Array | List of node properties for which to add helper methods to the tree traversal. |
- Source:
Returns:
a new tree traversal.
- Type
- TreeTraversal
Examples
// Basic usage
traversal()
// Handle nodes with `.name === 'wowza'`
.addHandler('name', 'wowza', function(node, recur) {})
// Handle nodes with `.name === 'gene'`
.addHandler('name', 'gene', function(node, recur) {})
// Handle nodes with `.value === 42`
.addHandler('value', 42, function(node, recur) {})
// Run the traversal on a root node
.run(rootNode);
// Add helper method to make thing faster
traversal(['name', 'value'])
.name('wowza', function(node, recur) {})
.name('gene', function(node, recur) {})
.value(42, function(node, recur) {})
.run(rootNode);
Type Definitions
recur(node, givenDepthopt)
Recurs further into the traversal given the next node.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
node |
Object | Node on which to continue the traversal. | |
givenDepth |
Number |
<optional> |
Traversal depth override. |