import type { Entry } from "./entry.js"; import type { AnyCaller } from "./function.js"; /** `Map` that cannot be changed. */ export type ImmutableMap = ReadonlyMap; /** Class for a `Map` that cannot be changed (so you can extend `Map` while implementing `ImmutableMap`). */ export declare const ImmutableMap: { new (...params: ConstructorParameters>): ImmutableMap; }; /** `Map` that can be changed. */ export type MutableMap = Map; /** Extract the type for the value of a map. */ export type MapKey = X extends ReadonlyMap ? Y : never; /** Extract the type for the value of a map. */ export type MapValue = X extends ReadonlyMap ? Y : never; /** Get the type for an item of a map in entry format. */ export type MapItem = readonly [MapKey, MapValue]; /** Things that can be converted to maps. */ export type PossibleMap = ImmutableMap | Iterable>; /** Things that can be converted to maps with string keys. */ export type PossibleStringMap = PossibleMap | { readonly [KK in K]: T; }; /** Is an unknown value a map? */ export declare function isMap(value: unknown): value is ImmutableMap; /** Assert that a value is a `Map` instance. */ export declare function assertMap(value: unknown, caller?: AnyCaller): asserts value is ImmutableMap; /** Convert an iterable to a `Map` (if it's already a `Map` it passes through unchanged). */ export declare function getMap(input: PossibleStringMap): ImmutableMap; export declare function getMap(input: PossibleMap): ImmutableMap; /** Apply a limit to a map. */ export declare function limitMap(map: ImmutableMap, limit: number): ImmutableMap; /** Is an unknown value a key for an item in a map? */ export declare function isMapItem(map: ImmutableMap, key: unknown): key is K; /** Assert that an unknown value is a key for an item in a map. */ export declare function assertMapItem(map: ImmutableMap, key: unknown, caller?: AnyCaller): asserts key is K; /** Function that lets new items in a map be created and updated by calling a `reduce()` callback that receives the existing value. */ export declare function setMapItem(map: MutableMap, key: K, value: T): T; /** Add multiple items to a set (by reference). */ export declare function setMapItems(map: MutableMap, items: Iterable>>): void; /** Remove multiple items from a set (by reference). */ export declare function removeMapItems(map: MutableMap, ...keys: K[]): void; /** Get an item in a map, or `undefined` if it doesn't exist. */ export declare function getMapItem(map: ImmutableMap, key: K): T | undefined; /** Get an item in a map, or throw `RequiredError` if it doesn't exist. */ export declare function requireMapItem(map: ImmutableMap, key: K, caller?: AnyCaller): T;