/** * Chains over the values of the `HashSet` using the specified function. * * @tsplus static HashSet.Aspects flatMap * @tsplus pipeable HashSet flatMap */ export function flatMap(f: (a: A) => Collection) { return (self: HashSet): HashSet => { const set = HashSet.empty() return set.mutate((_) => { self.forEach((a) => { for (const b of f(a)) { if (!_.has(b)) { _.add(b) } } }) }) } }