immutable-partition
A partitioning helper returning an immutablejs
Map of Lists:
const someNumbers = Listconst evenOrOdd = number % 2 === 1 ? 'odd' : 'even'const partitions = console// > Map { "even": List [ 0, 2 ], "odd": List [ 1, 3 ] }
Install
npm i -S immutable-partition # or yarn add immutable-partition
Usage
partition
takes the two following arguments and returns a Map<K:string, V:List>
.
keyForValue(value: any): string
must return a stringreducible
just needs to have areduce
function so it can be anyimmutablejs
structure, a regular array or anything that acts like one.
partition
is curried so it can be called in two ways:
// orreducible