Module: util/itertools
Functions
groupBy
▸ groupBy<T, U>(list, func): Map<U, T[]>
Returns a map where the elements are grouped based on the value of func for
the given elements.
Type parameters
| Name |
|---|
T |
U |
Parameters
| Name | Type | Description |
|---|---|---|
list | T[] | LIst of elements to group |
func | (element: T) => U | Function to map elements to group key |
Returns
Map<U, T[]>
Map from group keys to list of elements mapped to given key
Defined in
partition
▸ partition<T, U>(list, predicate): [T[], U[]]
Partitions a list into two lists, one containing all elements for which the
predicate returned true, the other containing all elements for which the
predicate returned false
Type parameters
| Name |
|---|
T |
U |
Parameters
| Name | Type | Description |
|---|---|---|
list | (T | U)[] | The list to partition |
predicate | (elem: T | U) => elem is T | The predicate to use to partition the list |
Returns
[T[], U[]]
A tuple of two lists, the first containing all elements for which
the predicate returned true, the second containing all elements for which the
predicate returned false