Mangler.explore() - DarthJDG/Mangler.js GitHub Wiki
Traverses all nested objects and arrays, calling a function for each key/value pair.
Mangler.explore(iterable, callback[, state])| Parameter | Type | Default | Description |
|---|---|---|---|
| iterable | Iterable | Iterable object to loop through recursively. | |
| callback | Function | Function to call for each key/value pair. Parameters: function(key, value, state). See below for details. |
|
| state | Object | {} |
Initial value of the state object passed down the hierarchy. |
Nothing.
| Property | Type | Description |
|---|---|---|
| $path | String | Describes the current value's path from the root of the iteration. |
| $parent | Instance | Points to the object which has the current value at the given key. |
| $parentPath | String | The path of the parent from the root of the iteration. |
| $prop | String | The last known property name of the value. If the current value is an array element, it looks further up the path. If the it's an object property, state.$prop is the same as key. Could be an empty string if there's no object property in the path. |
This function is also used internally by some Mangler.js methods. It is identical to the .explore() mangler object method, but allows you to traverse any iterable object or array passed as the first iterable parameter.
For a mangler object m, the following calls are identical:
m.explore(callback, state);
Mangler.explore(m, callback, state);
Mangler.explore(m.items, callback, state);See .explore() for more information and usage.