.aggregate() - DarthJDG/Mangler.js GitHub Wiki
Processes items in a loop and returns a single or grouped result.
.aggregate([function[, options]])| Parameter | Type | Default | Description |
|---|---|---|---|
| function | String Function |
'sum' |
The name of the aggregator function to use or a custom function. |
| options | Object | An object containing optional method modifiers. |
The aggregated result.
| Property | Type | Default | Description |
|---|---|---|---|
| value | String Function false |
false | Indicates how to get the values to aggregate. It is either a string path to process with Mangler.getPath() or a custom function in the form of function(item) returning the value to use. If false, the item from the iterable is used directly. |
| group | String Function false |
false | Indicates how to get the group's name for grouped results. It is either a string path to process with Mangler.getPath() or a custom function in the form of function(key, value) returning the group name. If false, results will not be grouped and a single aggregated value is returned. |
Calls Mangler.aggregate() with the .items[ ] array as the implicit first parameter. See Mangler.aggregate() for more information.