<V>(value: unknown): value is MutableHashSet<V>Checks whether the specified value is a MutableHashSet, false otherwise.
When to use
Use to narrow an unknown value before treating it as a mutable hash set.
Details
The check looks for the MutableHashSet runtime marker.
Gotchas
Native Set values do not satisfy this check.
export const const isMutableHashSet: <V>(
value: unknown
) => value is MutableHashSet<V>
Checks whether the specified value is a MutableHashSet, false otherwise.
When to use
Use to narrow an unknown value before treating it as a mutable hash set.
Details
The check looks for the MutableHashSet runtime marker.
Gotchas
Native Set values do not satisfy this check.
isMutableHashSet = <function (type parameter) V in <V>(value: unknown): value is MutableHashSet<V>V>(value: unknownvalue: unknown): value: unknownvalue is interface MutableHashSet<out V>A mutable hash set for storing unique values with Effect structural equality
support.
When to use
Use to store and mutate a collection of unique values with Effect hashing and
equality semantics.
Details
Operations mutate the set in place. Values that implement Equal / Hash
can be de-duplicated structurally; other values use normal JavaScript
reference or primitive equality.
Example (Using a mutable hash set)
import { MutableHashSet } from "effect"
// Create a mutable hash set
const set: MutableHashSet.MutableHashSet<string> = MutableHashSet.make(
"apple",
"banana"
)
// Add elements
MutableHashSet.add(set, "cherry")
// Check if elements exist
console.log(MutableHashSet.has(set, "apple")) // true
console.log(MutableHashSet.has(set, "grape")) // false
// Iterate over elements
for (const value of set) {
console.log(value) // "apple", "banana", "cherry"
}
// Get size
console.log(MutableHashSet.size(set)) // 3
MutableHashSet<function (type parameter) V in <V>(value: unknown): value is MutableHashSet<V>V> => hasProperty<"~effect/collections/MutableHashSet">(self: unknown, property: "~effect/collections/MutableHashSet"): self is { [K in "~effect/collections/MutableHashSet"]: unknown; } (+1 overload)Checks whether a value has a given property key.
When to use
Use when you need a Predicate guard for property access on unknown
values with a simple structural object check.
Details
Uses the in operator and isObjectKeyword. This does not check property
value types.
Example (Guarding object properties)
import { Predicate } from "effect"
const hasName = Predicate.hasProperty("name")
const data: unknown = { name: "Ada" }
if (hasName(data)) {
console.log(data.name)
}
hasProperty(value: unknownvalue, const TypeId: "~effect/collections/MutableHashSet"TypeId)