Function: toMap()
toMap<
Key
,Value
>():RawKeyedReducer
<Key
,Value
,Map
<Key
,Value
>>
Returns a KeyedReducer that collects key-value pairs to a Map
.
In the case of pairs with duplicate keys, the value of the last one wins.
Type Parameters
• Key
• Value
Returns
RawKeyedReducer
<Key
, Value
, Map
<Key
, Value
>>
Example
import { map, pipe, reduce, toMap } from 'lfi'
console.log(
pipe(
[`sloth`, `lazy`, `sleep`],
map(word => [word, word.length]),
reduce(toMap()),
),
)
//=> Map(3) {
//=> 'sloth' => 5,
//=> 'lazy' => 4,
//=> 'sleep' => 5
//=> }
Since
v0.0.1