Skip to main content

Function: toWeakSet()

toWeakSet<Value>(): Reducer<Value, WeakSet<Value>>

Returns a Reducer that collects objects to a WeakSet.

Type Parameters

Value extends object

Returns

Reducer<Value, WeakSet<Value>>

Example

import { cycle, map, pipe, reduce, take, toWeakSet } from 'lfi'

console.log(
pipe(
cycle([`sloth`, `lazy`, `sleep`]),
take(4),
map(word => ({ sloth: word })),
reduce(toWeakSet()),
),
)
//=> WeakSet { <items unknown> }
Playground

Since

v0.0.1

Defined in

collections.d.ts:82