<K>(key: K): <V>(self: MutableHashMap<K, V>) => boolean
<K, V>(self: MutableHashMap<K, V>, key: K): booleanChecks whether the MutableHashMap contains the specified key.
When to use
Use to test whether a key is present in a MutableHashMap without reading
its value.
Example (Checking for a key)
import { MutableHashMap } from "effect"
const map = MutableHashMap.make(["key1", 42], ["key2", 100])
console.log(MutableHashMap.has(map, "key1")) // true
console.log(MutableHashMap.has(map, "key3")) // false
// Pipe-able version
const hasKey = MutableHashMap.has("key1")
console.log(hasKey(map)) // trueexport const const has: {
<K>(key: K): <V>(
self: MutableHashMap<K, V>
) => boolean
<K, V>(
self: MutableHashMap<K, V>,
key: K
): boolean
}
Checks whether the MutableHashMap contains the specified key.
When to use
Use to test whether a key is present in a MutableHashMap without reading
its value.
Example (Checking for a key)
import { MutableHashMap } from "effect"
const map = MutableHashMap.make(["key1", 42], ["key2", 100])
console.log(MutableHashMap.has(map, "key1")) // true
console.log(MutableHashMap.has(map, "key3")) // false
// Pipe-able version
const hasKey = MutableHashMap.has("key1")
console.log(hasKey(map)) // true
has: {
<function (type parameter) K in <K>(key: K): <V>(self: MutableHashMap<K, V>) => booleanK>(key: Kkey: function (type parameter) K in <K>(key: K): <V>(self: MutableHashMap<K, V>) => booleanK): <function (type parameter) V in <V>(self: MutableHashMap<K, V>): booleanV>(self: MutableHashMap<K, V>(parameter) self: {
backing: Map<K, V>;
buckets: Map<number, NonEmptyArray<K>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: 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>(key: K): <V>(self: MutableHashMap<K, V>) => booleanK, function (type parameter) V in <V>(self: MutableHashMap<K, V>): booleanV>) => boolean
<function (type parameter) K in <K, V>(self: MutableHashMap<K, V>, key: K): booleanK, function (type parameter) V in <K, V>(self: MutableHashMap<K, V>, key: K): booleanV>(self: MutableHashMap<K, V>(parameter) self: {
backing: Map<K, V>;
buckets: Map<number, NonEmptyArray<K>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: 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>(self: MutableHashMap<K, V>, key: K): booleanK, function (type parameter) V in <K, V>(self: MutableHashMap<K, V>, key: K): booleanV>, key: Kkey: function (type parameter) K in <K, V>(self: MutableHashMap<K, V>, key: K): booleanK): boolean
} = import dualdual<
<function (type parameter) K in <K>(key: K): <V>(self: MutableHashMap<K, V>) => booleanK>(key: Kkey: function (type parameter) K in <K>(key: K): <V>(self: MutableHashMap<K, V>) => booleanK) => <function (type parameter) V in <V>(self: MutableHashMap<K, V>): booleanV>(self: MutableHashMap<K, V>(parameter) self: {
backing: Map<K, V>;
buckets: Map<number, NonEmptyArray<K>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: 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>(key: K): <V>(self: MutableHashMap<K, V>) => booleanK, function (type parameter) V in <V>(self: MutableHashMap<K, V>): booleanV>) => boolean,
<function (type parameter) K in <K, V>(self: MutableHashMap<K, V>, key: K): booleanK, function (type parameter) V in <K, V>(self: MutableHashMap<K, V>, key: K): booleanV>(self: MutableHashMap<K, V>(parameter) self: {
backing: Map<K, V>;
buckets: Map<number, NonEmptyArray<K>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: 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>(self: MutableHashMap<K, V>, key: K): booleanK, function (type parameter) V in <K, V>(self: MutableHashMap<K, V>, key: K): booleanV>, key: Kkey: function (type parameter) K in <K, V>(self: MutableHashMap<K, V>, key: K): booleanK) => boolean
>(2, (self: MutableHashMap<K, V>(parameter) self: {
backing: Map<K, V>;
buckets: Map<number, NonEmptyArray<K>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, key: anykey) => import OptionOption.const isSome: <A>(
self: Option<A>
) => self is Some<A>
Checks whether an Option contains a value (Some).
When to use
Use when you need to branch on a present Option before accessing .value.
Details
- Acts as a type guard, narrowing to
Some<A>
Example (Checking for Some)
import { Option } from "effect"
console.log(Option.isSome(Option.some(1)))
// Output: true
console.log(Option.isSome(Option.none()))
// Output: false
isSome(const get: {
<K>(key: K): <V>(
self: MutableHashMap<K, V>
) => Option.Option<V>
<K, V>(
self: MutableHashMap<K, V>,
key: K
): Option.Option<V>
}
get(self: MutableHashMap<K, V>(parameter) self: {
backing: Map<K, V>;
buckets: Map<number, NonEmptyArray<K>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, key: anykey)))