<K, V>(value: unknown): value is MutableHashMap<K, V>Checks whether the specified value is a MutableHashMap, false otherwise.
When to use
Use to narrow an unknown value before treating it as a mutable hash map.
Details
The check looks for the MutableHashMap runtime marker.
Gotchas
The check does not validate the key or value types carried by the map.
export const const isMutableHashMap: <K, V>(
value: unknown
) => value is MutableHashMap<K, V>
Checks whether the specified value is a MutableHashMap, false otherwise.
When to use
Use to narrow an unknown value before treating it as a mutable hash map.
Details
The check looks for the MutableHashMap runtime marker.
Gotchas
The check does not validate the key or value types carried by the map.
isMutableHashMap = <function (type parameter) K in <K, V>(value: unknown): value is MutableHashMap<K, V>K, function (type parameter) V in <K, V>(value: unknown): value is MutableHashMap<K, V>V>(value: unknownvalue: unknown): value: unknownvalue is interface MutableHashMap<out K, out V>A mutable hash map that stores key-value pairs and supports both referential
and Effect structural equality.
When to use
Use as a mutable key-value map when in-place updates are acceptable and keys
may rely on Effect structural equality.
Details
Operations mutate the map in place. Keys that implement Equal / Hash can
be looked up structurally; other keys use normal JavaScript reference or
primitive equality.
Example (Using a mutable hash map)
import { MutableHashMap } from "effect"
// Create a mutable hash map with string keys and number values
const map: MutableHashMap.MutableHashMap<string, number> = MutableHashMap
.empty()
// Add some data
MutableHashMap.set(map, "count", 42)
MutableHashMap.set(map, "total", 100)
// Use as iterable
for (const [key, value] of map) {
console.log(`${key}: ${value}`)
}
// Output:
// count: 42
// total: 100
// Convert to array
const entries = Array.from(map)
console.log(entries) // [["count", 42], ["total", 100]]
MutableHashMap<function (type parameter) K in <K, V>(value: unknown): value is MutableHashMap<K, V>K, function (type parameter) V in <K, V>(value: unknown): value is MutableHashMap<K, V>V> => hasProperty<"~effect/collections/MutableHashMap">(self: unknown, property: "~effect/collections/MutableHashMap"): self is { [K in "~effect/collections/MutableHashMap"]: 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/MutableHashMap"TypeId)