A partition helper returning ImmutableJS structures
npm install immutable-partition
A partitioning helper returning an immutablejs Map of Lists:
``js
import partition from 'immutable-partition'
const someNumbers = List.of(0, 1, 2, 3)
const evenOrOdd = (number) => number % 2 === 1 ? 'odd' : 'even'
const partitions = partition(evenOrOdd, someNumbers)
console.log(partitions.toString())
// > Map { "even": List [ 0, 2 ], "odd": List [ 1, 3 ] }
`
`sh
npm i -S immutable-partition
yarn add immutable-partition
`
partition takes the two following arguments and returns a Map.
* keyForValue(value: any): string must return a stringreducible
* just needs to have a reduce function so it can be any immutablejs structure, a regular array or anything that acts like one.
partition is curried so it can be called in two ways:
`js``
partition(keyForValue, reducible)
// or
partition(keyForValue)(reducible)