array-prototype-functions
Advanced tools
Comparing version 2.7.1 to 2.7.2
{ | ||
"name": "array-prototype-functions", | ||
"version": "2.7.1", | ||
"version": "2.7.2", | ||
"description": "Array prototype augmentation for easier arithmetics and overall pleasure!", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -174,8 +174,11 @@ <p align="center"> | ||
### `Array.prototype.groupBy(field)` | ||
### `Array.prototype.groupBy(fieldOrMapper)` | ||
Dependencies: none | ||
Returns a dictionary of lists of objects from the array grouped by a field name. The field name is required. | ||
Returns a dictionary of lists of objects from the array grouped by a field name. The `fieldOrMapper` is required and can be one of: | ||
- string - in which case it will be a name of field to extract from the objects in the array and then to sort them up | ||
- a function that takes the array element as parameter and shall return a string to group objects by | ||
Objects that don't have the field in them will be skipped. | ||
@@ -187,3 +190,7 @@ | ||
Returns a Map of lists of objects from the array grouped by a field name. The field name is required. | ||
Returns a Map of lists of objects from the array grouped by a field name. The `fieldOrMapper` is required and can be one of: | ||
- string - in which case it will be a name of field to extract from the objects in the array and then to sort them up | ||
- a function that takes the array element as parameter and shall return a value to group objects by | ||
The difference to `groupBy(field)` is that the return value is an instance of `Map<any, T[]>` which means that the original type of the values of the field is also preserved and not converted to a string. This also means that if throughout the objects in the source array field values have different types they will be treated differently and you'll end up having more than one item in the result. | ||
@@ -190,0 +197,0 @@ |
33445
228