Package: effect
Module: HashSet
Checks whether the HashSet contains the specified value.
Example (Checking HashSet membership)
import { Equal, Hash, HashSet } from "effect"
// Works with any type that implements Equal
const set = HashSet.make("apple", "banana", "cherry")
console.log(HashSet.has(set, "apple")) // true
console.log(HashSet.has(set, "grape")) // false
class Person implements Equal.Equal {
constructor(readonly name: string) {}
[Equal.symbol](other: unknown) {
return other instanceof Person && this.name === other.name
}
[Hash.symbol](): number {
return Hash.string(this.name)
}
}
const people = HashSet.make(new Person("Alice"), new Person("Bob"))
console.log(HashSet.has(people, new Person("Alice"))) // true
Signature
declare const has: { <V>(value: V): (self: HashSet<V>) => boolean; <V>(self: HashSet<V>, value: V): boolean; }
Since v2.0.0