Package: effect
Module: HashSet
Maps each value in the HashSet using the provided function.
Example (Mapping HashSet values)
import { HashSet } from "effect"
const numbers = HashSet.make(1, 2, 3)
const doubled = HashSet.map(numbers, (n) => n * 2)
console.log(Array.from(doubled).sort()) // [2, 4, 6]
console.log(HashSet.size(doubled)) // 3
// Mapping can reduce size if function produces duplicates
const strings = HashSet.make("apple", "banana", "cherry")
const lengths = HashSet.map(strings, (s) => s.length)
console.log(Array.from(lengths).sort()) // [5, 6] (apple=5, banana=6, cherry=6)
Signature
declare const map: { <V, U>(f: (value: V) => U): (self: HashSet<V>) => HashSet<U>; <V, U>(self: HashSet<V>, f: (value: V) => U): HashSet<U>; }
Since v2.0.0