import { Nullable } from '../../types/general'; import { Immutable } from './immutable'; /** The `ImmutableMap` class is a TypeScript implementation of an immutable map data structure that allows for mutation through a `withMutation` method. */ export declare class ImmutableMap implements Immutable> { size: number; private readonly map; /** * The constructor initializes a new ImmutableMap object with an optional initial value and an optional callback function for mutation events. * * @param {Map} [initialValue] - The `initialValue` parameter is an optional parameter that allows you to * provide an initial value for the `Map`. It is of type `Map`, where `K` represents the key * type and `V` represents the value type. * @param {(newMap: ImmutableMap) => void} [onMutate] - The `onMutate` parameter is a callback function that is called whenever the * `ImmutableMap` is mutated (i.e., when a key-value pair is added, updated, or removed). It receives * the new `ImmutableMap` as an argument. This callback function can be used to perform any */ constructor(initialValue: Map, onMutate?: (newMap: ImmutableMap) => void); /** * The "has" function checks if a key exists in a map. * * @param {unknown} key - The parameter "key" is of type K, which means it can be any type. It is used to specify the key that you want to check for existence in the map. * @returns {boolean} A boolean value indicating whether the key exists in the map. */ has(key: K): boolean; /** * The function returns an iterator of the keys in a map. * * @typedef K generic type * @returns {IterableIterator} The `keys()` method is returning an `IterableIterator` object that contains the keys of the `map`. */ keys(): IterableIterator; /** * The `set` function adds a key-value pair to an immutable map. * * @typedef K generic type * @typedef V generic type * @param {unknown} key - The key parameter is the key of the entry that you want to add or update in the map. It is of type K, which represents the type of the keys in the map. * @param {unknown} value - The value parameter represents the value that you want to associate with the specified key in the ImmutableMap. * @returns {ImmutableMap} The method is returning an ImmutableMap. */ set(key: K, value: V): ImmutableMap; /** * The get function retrieves the value associated with a given key from a map. * * @typedef V generic type * @param {unknown} key - The parameter "key" is of type "K", which means it can be any type. * @returns {Nullable} The value associated with the given key in the map. */ get(key: K): Nullable; /** * The values() method of Map instances returns a new map iterator object that contains the values for each element in this map in insertion order. * * @typedef V generic type * @returns {IterableIterator} An iterator of the values in the map. */ values(): IterableIterator; /** * The `delete` function removes an entry from an ImmutableMap by deleting the corresponding key-value pair from the underlying Map. * * @typedef K generic type * @typedef V generic type * @param {unknown} key - The key parameter is the key of the entry that you want to delete from the ImmutableMap. * @returns {ImmutableMap} The method is returning an ImmutableMap. */ delete(key: K): ImmutableMap; /** * The `clear` function clears all key-value pairs from an ImmutableMap. * * @typedef K generic type * @typedef V generic type * @returns {ImmutableMap} The method is returning an ImmutableMap. */ clear(): ImmutableMap; /** * The function is called when the map is mutated * * @param {ImmutableMap} _newMap - The new set that was created. */ onMutate(_newMap: ImmutableMap): void; /** * The `withMutation` function takes a callback function that mutates a map and returns a new immutable map with the changes applied. * * @typedef K generic type * @typedef V generic type * @param {(map: Map) => void} fn - A function that takes a map as its parameter and does some mutation on it. * @returns {ImmutableMap} a new instance of `ImmutableMap`. */ withMutation(fn: (map: Map) => void): ImmutableMap; }