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