/** * @since 2.0.0 */ import type { Equal } from "./Equal.js"; import type { HashSet } from "./HashSet.js"; import type { Inspectable } from "./Inspectable.js"; import type { Option } from "./Option.js"; import type { Pipeable } from "./Pipeable.js"; import type { NoInfer } from "./Types.js"; declare const TypeId: unique symbol; /** * @since 2.0.0 * @category symbol */ export type TypeId = typeof TypeId; /** * @since 2.0.0 * @category models */ export interface HashMap extends Iterable<[Key, Value]>, Equal, Pipeable, Inspectable { readonly [TypeId]: TypeId; } /** * @since 2.0.0 */ export declare namespace HashMap { /** * @since 2.0.0 * @category models */ type UpdateFn = (option: Option) => Option; /** * This type-level utility extracts the key type `K` from a `HashMap` type. * * @example * ```ts * import { HashMap } from "effect" * * declare const hm: HashMap.HashMap * * // $ExpectType string * type K = HashMap.HashMap.Key * * ``` * @since 2.0.0 * @category type-level */ type Key> = [T] extends [HashMap] ? _K : never; /** * This type-level utility extracts the value type `V` from a `HashMap` type. * * @example * ```ts * import { HashMap } from "effect" * * declare const hm: HashMap.HashMap * * // $ExpectType number * type V = HashMap.HashMap.Value * * ``` * @since 2.0.0 * @category type-level */ type Value> = [T] extends [HashMap] ? _V : never; /** * This type-level utility extracts the entry type `[K, V]` from a `HashMap` type. * * @example * ```ts * import { HashMap } from "effect" * * declare const hm: HashMap.HashMap * * // $ExpectType [string, number] * type V = HashMap.HashMap.Entry * * ``` * @since 3.9.0 * @category type-level */ type Entry> = [Key, Value]; } /** * @since 2.0.0 * @category refinements */ export declare const isHashMap: { /** * @since 2.0.0 * @category refinements */ (u: Iterable): u is HashMap; /** * @since 2.0.0 * @category refinements */ (u: unknown): u is HashMap; }; /** * Creates a new `HashMap`. * * @since 2.0.0 * @category constructors */ export declare const empty: () => HashMap; /** * Constructs a new `HashMap` from an array of key/value pairs. * * @since 2.0.0 * @category constructors */ export declare const make: >(...entries: Entries) => HashMap; /** * Creates a new `HashMap` from an iterable collection of key/value pairs. * * @since 2.0.0 * @category constructors */ export declare const fromIterable: (entries: Iterable) => HashMap; /** * Checks if the `HashMap` contains any entries. * * @since 2.0.0 * @category elements */ export declare const isEmpty: (self: HashMap) => boolean; /** * Safely lookup the value for the specified key in the `HashMap` using the * internal hashing function. * * @since 2.0.0 * @category elements */ export declare const get: { /** * Safely lookup the value for the specified key in the `HashMap` using the * internal hashing function. * * @since 2.0.0 * @category elements */ (key: K1): (self: HashMap) => Option; /** * Safely lookup the value for the specified key in the `HashMap` using the * internal hashing function. * * @since 2.0.0 * @category elements */ (self: HashMap, key: K1): Option; }; /** * Lookup the value for the specified key in the `HashMap` using a custom hash. * * @since 2.0.0 * @category elements */ export declare const getHash: { /** * Lookup the value for the specified key in the `HashMap` using a custom hash. * * @since 2.0.0 * @category elements */ (key: K1, hash: number): (self: HashMap) => Option; /** * Lookup the value for the specified key in the `HashMap` using a custom hash. * * @since 2.0.0 * @category elements */ (self: HashMap, key: K1, hash: number): Option; }; /** * Unsafely lookup the value for the specified key in the `HashMap` using the * internal hashing function. * * @since 2.0.0 * @category unsafe */ export declare const unsafeGet: { /** * Unsafely lookup the value for the specified key in the `HashMap` using the * internal hashing function. * * @since 2.0.0 * @category unsafe */ (key: K1): (self: HashMap) => V; /** * Unsafely lookup the value for the specified key in the `HashMap` using the * internal hashing function. * * @since 2.0.0 * @category unsafe */ (self: HashMap, key: K1): V; }; /** * Checks if the specified key has an entry in the `HashMap`. * * @since 2.0.0 * @category elements */ export declare const has: { /** * Checks if the specified key has an entry in the `HashMap`. * * @since 2.0.0 * @category elements */ (key: K1): (self: HashMap) => boolean; /** * Checks if the specified key has an entry in the `HashMap`. * * @since 2.0.0 * @category elements */ (self: HashMap, key: K1): boolean; }; /** * Checks if the specified key has an entry in the `HashMap` using a custom * hash. * * @since 2.0.0 * @category elements */ export declare const hasHash: { /** * Checks if the specified key has an entry in the `HashMap` using a custom * hash. * * @since 2.0.0 * @category elements */ (key: K1, hash: number): (self: HashMap) => boolean; /** * Checks if the specified key has an entry in the `HashMap` using a custom * hash. * * @since 2.0.0 * @category elements */ (self: HashMap, key: K1, hash: number): boolean; }; /** * Checks if an element matching the given predicate exists in the given `HashMap`. * * @example * ```ts * import { HashMap } from "effect" * * const hm = HashMap.make([1, 'a']) * HashMap.hasBy(hm, (value, key) => value === 'a' && key === 1); // -> true * HashMap.hasBy(hm, (value) => value === 'b'); // -> false * * ``` * * @since 3.16.0 * @category elements */ export declare const hasBy: { /** * Checks if an element matching the given predicate exists in the given `HashMap`. * * @example * ```ts * import { HashMap } from "effect" * * const hm = HashMap.make([1, 'a']) * HashMap.hasBy(hm, (value, key) => value === 'a' && key === 1); // -> true * HashMap.hasBy(hm, (value) => value === 'b'); // -> false * * ``` * * @since 3.16.0 * @category elements */ (predicate: (value: NoInfer, key: NoInfer) => boolean): (self: HashMap) => boolean; /** * Checks if an element matching the given predicate exists in the given `HashMap`. * * @example * ```ts * import { HashMap } from "effect" * * const hm = HashMap.make([1, 'a']) * HashMap.hasBy(hm, (value, key) => value === 'a' && key === 1); // -> true * HashMap.hasBy(hm, (value) => value === 'b'); // -> false * * ``` * * @since 3.16.0 * @category elements */ (self: HashMap, predicate: (value: NoInfer, key: NoInfer) => boolean): boolean; }; /** * Sets the specified key to the specified value using the internal hashing * function. * * @since 2.0.0 */ export declare const set: { /** * Sets the specified key to the specified value using the internal hashing * function. * * @since 2.0.0 */ (key: K, value: V): (self: HashMap) => HashMap; /** * Sets the specified key to the specified value using the internal hashing * function. * * @since 2.0.0 */ (self: HashMap, key: K, value: V): HashMap; }; /** * Returns an `IterableIterator` of the keys within the `HashMap`. * * @since 2.0.0 * @category getters */ export declare const keys: (self: HashMap) => IterableIterator; /** * Returns a `HashSet` of keys within the `HashMap`. * * @since 2.0.0 * @category getter */ export declare const keySet: (self: HashMap) => HashSet; /** * Returns an `IterableIterator` of the values within the `HashMap`. * * @since 2.0.0 * @category getters */ export declare const values: (self: HashMap) => IterableIterator; /** * Returns an `Array` of the values within the `HashMap`. * * @since 3.13.0 * @category getters */ export declare const toValues: (self: HashMap) => Array; /** * Returns an `IterableIterator` of the entries within the `HashMap`. * * @since 2.0.0 * @category getters */ export declare const entries: (self: HashMap) => IterableIterator<[K, V]>; /** * Returns an `Array<[K, V]>` of the entries within the `HashMap`. * * @since 2.0.0 * @category getters */ export declare const toEntries: (self: HashMap) => Array<[K, V]>; /** * Returns the number of entries within the `HashMap`. * * @since 2.0.0 * @category getters */ export declare const size: (self: HashMap) => number; /** * Marks the `HashMap` as mutable. * * @since 2.0.0 */ export declare const beginMutation: (self: HashMap) => HashMap; /** * Marks the `HashMap` as immutable. * * @since 2.0.0 */ export declare const endMutation: (self: HashMap) => HashMap; /** * Mutates the `HashMap` within the context of the provided function. * * @since 2.0.0 */ export declare const mutate: { /** * Mutates the `HashMap` within the context of the provided function. * * @since 2.0.0 */ (f: (self: HashMap) => void): (self: HashMap) => HashMap; /** * Mutates the `HashMap` within the context of the provided function. * * @since 2.0.0 */ (self: HashMap, f: (self: HashMap) => void): HashMap; }; /** * Set or remove the specified key in the `HashMap` using the specified * update function. The value of the specified key will be computed using the * provided hash. * * The update function will be invoked with the current value of the key if it * exists, or `None` if no such value exists. * * @since 2.0.0 */ export declare const modifyAt: { /** * Set or remove the specified key in the `HashMap` using the specified * update function. The value of the specified key will be computed using the * provided hash. * * The update function will be invoked with the current value of the key if it * exists, or `None` if no such value exists. * * @since 2.0.0 */ (key: K, f: HashMap.UpdateFn): (self: HashMap) => HashMap; /** * Set or remove the specified key in the `HashMap` using the specified * update function. The value of the specified key will be computed using the * provided hash. * * The update function will be invoked with the current value of the key if it * exists, or `None` if no such value exists. * * @since 2.0.0 */ (self: HashMap, key: K, f: HashMap.UpdateFn): HashMap; }; /** * Alter the value of the specified key in the `HashMap` using the specified * update function. The value of the specified key will be computed using the * provided hash. * * The update function will be invoked with the current value of the key if it * exists, or `None` if no such value exists. * * This function will always either update or insert a value into the `HashMap`. * * @since 2.0.0 */ export declare const modifyHash: { /** * Alter the value of the specified key in the `HashMap` using the specified * update function. The value of the specified key will be computed using the * provided hash. * * The update function will be invoked with the current value of the key if it * exists, or `None` if no such value exists. * * This function will always either update or insert a value into the `HashMap`. * * @since 2.0.0 */ (key: K, hash: number, f: HashMap.UpdateFn): (self: HashMap) => HashMap; /** * Alter the value of the specified key in the `HashMap` using the specified * update function. The value of the specified key will be computed using the * provided hash. * * The update function will be invoked with the current value of the key if it * exists, or `None` if no such value exists. * * This function will always either update or insert a value into the `HashMap`. * * @since 2.0.0 */ (self: HashMap, key: K, hash: number, f: HashMap.UpdateFn): HashMap; }; /** * Updates the value of the specified key within the `HashMap` if it exists. * * @since 2.0.0 */ export declare const modify: { /** * Updates the value of the specified key within the `HashMap` if it exists. * * @since 2.0.0 */ (key: K, f: (v: V) => V): (self: HashMap) => HashMap; /** * Updates the value of the specified key within the `HashMap` if it exists. * * @since 2.0.0 */ (self: HashMap, key: K, f: (v: V) => V): HashMap; }; /** * Performs a union of this `HashMap` and that `HashMap`. * * @since 2.0.0 */ export declare const union: { /** * Performs a union of this `HashMap` and that `HashMap`. * * @since 2.0.0 */ (that: HashMap): (self: HashMap) => HashMap; /** * Performs a union of this `HashMap` and that `HashMap`. * * @since 2.0.0 */ (self: HashMap, that: HashMap): HashMap; }; /** * Remove the entry for the specified key in the `HashMap` using the internal * hashing function. * * @since 2.0.0 */ export declare const remove: { /** * Remove the entry for the specified key in the `HashMap` using the internal * hashing function. * * @since 2.0.0 */ (key: K): (self: HashMap) => HashMap; /** * Remove the entry for the specified key in the `HashMap` using the internal * hashing function. * * @since 2.0.0 */ (self: HashMap, key: K): HashMap; }; /** * Removes all entries in the `HashMap` which have the specified keys. * * @since 2.0.0 */ export declare const removeMany: { /** * Removes all entries in the `HashMap` which have the specified keys. * * @since 2.0.0 */ (keys: Iterable): (self: HashMap) => HashMap; /** * Removes all entries in the `HashMap` which have the specified keys. * * @since 2.0.0 */ (self: HashMap, keys: Iterable): HashMap; }; /** * Maps over the entries of the `HashMap` using the specified function. * * @since 2.0.0 * @category mapping */ export declare const map: { /** * Maps over the entries of the `HashMap` using the specified function. * * @since 2.0.0 * @category mapping */ (f: (value: V, key: K) => A): (self: HashMap) => HashMap; /** * Maps over the entries of the `HashMap` using the specified function. * * @since 2.0.0 * @category mapping */ (self: HashMap, f: (value: V, key: K) => A): HashMap; }; /** * Chains over the entries of the `HashMap` using the specified function. * * **NOTE**: the hash and equal of both maps have to be the same. * * @since 2.0.0 * @category sequencing */ export declare const flatMap: { /** * Chains over the entries of the `HashMap` using the specified function. * * **NOTE**: the hash and equal of both maps have to be the same. * * @since 2.0.0 * @category sequencing */ (f: (value: A, key: K) => HashMap): (self: HashMap) => HashMap; /** * Chains over the entries of the `HashMap` using the specified function. * * **NOTE**: the hash and equal of both maps have to be the same. * * @since 2.0.0 * @category sequencing */ (self: HashMap, f: (value: A, key: K) => HashMap): HashMap; }; /** * Applies the specified function to the entries of the `HashMap`. * * @since 2.0.0 * @category traversing */ export declare const forEach: { /** * Applies the specified function to the entries of the `HashMap`. * * @since 2.0.0 * @category traversing */ (f: (value: V, key: K) => void): (self: HashMap) => void; /** * Applies the specified function to the entries of the `HashMap`. * * @since 2.0.0 * @category traversing */ (self: HashMap, f: (value: V, key: K) => void): void; }; /** * Reduces the specified state over the entries of the `HashMap`. * * @since 2.0.0 * @category folding */ export declare const reduce: { /** * Reduces the specified state over the entries of the `HashMap`. * * @since 2.0.0 * @category folding */ (zero: Z, f: (accumulator: Z, value: V, key: K) => Z): (self: HashMap) => Z; /** * Reduces the specified state over the entries of the `HashMap`. * * @since 2.0.0 * @category folding */ (self: HashMap, zero: Z, f: (accumulator: Z, value: V, key: K) => Z): Z; }; /** * Filters entries out of a `HashMap` using the specified predicate. * * @since 2.0.0 * @category filtering */ export declare const filter: { /** * Filters entries out of a `HashMap` using the specified predicate. * * @since 2.0.0 * @category filtering */ (f: (a: NoInfer, k: K) => a is B): (self: HashMap) => HashMap; /** * Filters entries out of a `HashMap` using the specified predicate. * * @since 2.0.0 * @category filtering */ (f: (a: NoInfer, k: K) => boolean): (self: HashMap) => HashMap; /** * Filters entries out of a `HashMap` using the specified predicate. * * @since 2.0.0 * @category filtering */ (self: HashMap, f: (a: A, k: K) => a is B): HashMap; /** * Filters entries out of a `HashMap` using the specified predicate. * * @since 2.0.0 * @category filtering */ (self: HashMap, f: (a: A, k: K) => boolean): HashMap; }; /** * Filters out `None` values from a `HashMap` of `Options`s. * * @since 2.0.0 * @category filtering */ export declare const compact: (self: HashMap>) => HashMap; /** * Maps over the entries of the `HashMap` using the specified partial function * and filters out `None` values. * * @since 2.0.0 * @category filtering */ export declare const filterMap: { /** * Maps over the entries of the `HashMap` using the specified partial function * and filters out `None` values. * * @since 2.0.0 * @category filtering */ (f: (value: A, key: K) => Option): (self: HashMap) => HashMap; /** * Maps over the entries of the `HashMap` using the specified partial function * and filters out `None` values. * * @since 2.0.0 * @category filtering */ (self: HashMap, f: (value: A, key: K) => Option): HashMap; }; /** * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * * @category elements * @since 2.0.0 */ export declare const findFirst: { /** * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * * @category elements * @since 2.0.0 */ (predicate: (a: NoInfer, k: K) => a is B): (self: HashMap) => Option<[K, B]>; /** * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * * @category elements * @since 2.0.0 */ (predicate: (a: NoInfer, k: K) => boolean): (self: HashMap) => Option<[K, A]>; /** * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * * @category elements * @since 2.0.0 */ (self: HashMap, predicate: (a: A, k: K) => a is B): Option<[K, B]>; /** * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * * @category elements * @since 2.0.0 */ (self: HashMap, predicate: (a: A, k: K) => boolean): Option<[K, A]>; }; /** * Checks if any entry in a hashmap meets a specific condition. * * @since 3.13.0 * @category elements */ export declare const some: { /** * Checks if any entry in a hashmap meets a specific condition. * * @since 3.13.0 * @category elements */ (predicate: (a: NoInfer, k: K) => boolean): (self: HashMap) => boolean; /** * Checks if any entry in a hashmap meets a specific condition. * * @since 3.13.0 * @category elements */ (self: HashMap, predicate: (a: A, k: K) => boolean): boolean; }; /** * Checks if all entries in a hashmap meets a specific condition. * * @param self - The hashmap to check. * @param predicate - The condition to test entries (value, key). * * @since 3.14.0 * @category elements */ export declare const every: { /** * Checks if all entries in a hashmap meets a specific condition. * * @param self - The hashmap to check. * @param predicate - The condition to test entries (value, key). * * @since 3.14.0 * @category elements */ (predicate: (a: NoInfer, k: K) => boolean): (self: HashMap) => boolean; /** * Checks if all entries in a hashmap meets a specific condition. * * @param self - The hashmap to check. * @param predicate - The condition to test entries (value, key). * * @since 3.14.0 * @category elements */ (self: HashMap, predicate: (a: A, k: K) => boolean): boolean; }; export {}; //# sourceMappingURL=HashMap.d.ts.map