Variable: toObject()
consttoObject: <Key,Value>() =>RawKeyedReducer<Key,Value,Record<Key,Value>>
Defined in: collections.d.ts:113
Returns a KeyedReducer that collects key-value pairs to an object.
In the case of pairs with duplicate keys, the value of the last one wins.
Type Parameters
Key
Key extends PropertyKey
Value
Value
Returns
RawKeyedReducer<Key, Value, Record<Key, Value>>
Example
import { map, pipe, reduce, toObject } from 'lfi'
console.log(
pipe(
[`sloth`, `lazy`, `sleep`],
map(word => [word, word.length]),
reduce(toObject()),
),
)
//=> {
//=> sloth: 5,
//=> lazy: 4,
//=> sleep: 5
//=> }
Since
v0.0.1