@tomzer0/collections
v1.0.1
Published
Array collection functions
Downloads
3
Readme
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 arrayassociate(arr, keySelector, valueSelector)
: {}, associates every value in arr to k -> vchunked(arr, size, transform)
: [], chunks elements in arr and then transforms the chunkunion(...arrs)
: [], returns union of all arrs.distinct(arr)
: [], distinct elements by equaldrop(arr, amt)
: [], drops amt cards from the arrdrop(arr, pred)
: [], drops first elems where pred is truetake(arr, amt)
: [], takes amt elems from arrtakeWhile(arr, pred)
: [], takes first elems where pred is truegroup(arr, keySelector)
: [], groups elements into sub arrays based on keySelectorpartition(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 from Kotlin Collections Library
License
MIT