TupleKeyedMap<K extends ReadonlyArray, V> Class

A map similar to the standard JavaScript Map collection except that the keys must be a tuple (javascript array), and two keys are considered equal if their elements in order are strict-equal, and the tuples have the same amount of elements

This means you can use array literals to key data in Maps that would otherwise be reference-compared if using JavaScript's built in Map

Note that JavaScript's Map type, unlike this one that uses strict equality, uses instead SameValueZero equality comparison

@see https://262.ecma-international.org/6.0/#sec-samevaluezero

const map = new TupleKeyedMap([[1,"y"], "value"]);
const value = map.get([1, "y"]); // a normal map would identify these keys as different because they are independent objects

It is implemented by each index of the tuple key being used as a singular key into a submap

@note this only implements a subset of the Map interface

Methods

Name Description
constructor<K extends ReadonlyArray, V>(entries?: "null" | ReadonlyArray): TupleKeyedMap<K, V>    
[iterator](): IterableIterator<[K, V]>    
clear(): void    
get(key: K): undefined | V    
has(key: K): boolean    
set(key: K, value: V): this    

Properties

Name Type Description
size Accessor ReadOnly number    
[toStringTag] Accessor ReadOnly string    

Defined in

Last Updated: 06 October, 2024