@tomzer0/collections
Version:
Array collection functions
31 lines (20 loc) • 1.15 kB
Markdown
# Collections
A basic collection of array functions.
## Installation
You know how to install it, or look up and to the right.
## Usage
- `flatten(arr)`: [], flattens the array
- `associate(arr, keySelector, valueSelector)`: {}, associates every value in arr to k -> v
- `chunked(arr, size, transform)`: [], chunks <size> elements in arr and then transforms the chunk
- `union(...arrs)`: [], returns union of all arrs.
- `distinct(arr)`: [], distinct elements by equal
- `drop(arr, amt)`: [], drops amt cards from the arr
- `drop(arr, pred)`: [], drops first elems where pred is true
- `take(arr, amt)`: [], takes amt elems from arr
- `takeWhile(arr, pred)`: [], takes first elems where pred is true
- `group(arr, keySelector)`: [], groups elements into sub arrays based on keySelector
- `partition(arr, pred)`: [ [falsy], [truthy] ], groups elements into two arrays, the first is falsy the second is truthy based on pred.
- `zip(arr1, arr2)`: [], pairs elements of arr1 and arr2 in result array
[Yoinked](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html) from Kotlin Collections Library
### License
MIT