A deep Map
npm install @xstd/deep-map
!npm
!NPM
!npm type definitions
!coverage

A _deep_ Map implementation.
``shell`
yarn add @xstd/deep-mapor
npm install @xstd/deep-map --save
The DeepMap object holds key-value pairs where the key is an Iterable of unknown values.
`tstrue
export declare class DeepMap
constructor(input?: Iterable
/**
* The number of elements present in the DeepMap.
*/
get size(): number;
/**
* Adds a new element with a specified key and value to the DeepMap.
* If an element with the same key already exists, the element will be updated.
*/
set(key: DeepMapKey, value: GValue): this;
/**
* Returns the element associated with the specified key from the DeepMap.
*
* @returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
*/
get(key: DeepMapKey): GValue | undefined;
/**
* Returns if the element associated with the specified key exists in the DeepMapfactory
*
* @returns boolean indicating whether an element with the specified key exists or not.
*/
has(key: DeepMapKey): boolean;
/**
* Returns the element associated with the specified key from the DeepMap.
* If this element does not exist, then is called, the returned value is inserted in the DeepMap, and this value is returned.`
*
* @returns the value existing or inserted associated with the specified key.
*/
upsert(key: DeepMapKey, factory: () => GValue): GValue;
/**
* Removes the element associated with the specified key from the DeepMap.
*
* @returns true if an element in the DeepMap existed and has been removed, or false if the element does not exist.
*/
delete(key: DeepMapKey): boolean;
/**
* Removes all elements from the DeepMap.
*/
clear(): void;
/**
* Returns an Iterable of key/value pairs for every entry in the DeepMap.
*/
entries(): Generator
/**
* Returns an Iterable of keys in the DeepMap.
*/
keys(): Generator
/**
* Returns an Iterable of values in the DeepMap.
*/
values(): Generator
/**
* Returns an Iterable of entries in the DeepMap.
*/
[Symbol.iterator](): Generator
/**
* Executes the provided function once per each key/value pair in the DeepMap.
*/
forEach(callbackFnc: (value: GValue, key: DeepMapKey, map: this) => void): void;
}
#### Example
`ts
const pool = new DeepMap
function getWebSocketFromPool(url: string | URL, protocol?: string): WebSocket {
return pool.upsert([url.toString(), protocol], () => new WebSocket(url, protocol));
}
const ws1 = getWebSocketFromPool('wss://echo.websocket.org/');
const ws2 = getWebSocketFromPool('wss://echo.websocket.org/');
console.assert(ws1 === ws2);
``