A drop-in replacement for the default ECMA Map implementation that uses hashes keys based on the string view of an Object.

Unlike the default ECMA Map implementation, this version does not maintain insertion order and does not make any guarantees on iteration order nor does enforce key identity equivalency when attempting to look up a mapping. This allows this implementation to store and compare objects that are equal, but not necessarily the same instance.

The hashing algorithm is based on that of Java's HashMap.

Type Parameters

  • K

    the type of the key

  • V

    the type of the value

Hierarchy

  • HashMap

Implements

  • Map<K, V>

Constructors

  • Constructs a new Map.

    Type Parameters

    • K

    • V

    Parameters

    • size: number = 32

      the number of buckets to spread entries across

    • Optional iterable: Iterable<[K, V]>

      initial entries to add to the map.

    Returns HashMap<K, V>

Properties

[toStringTag]: string = 'HashMap'

Inherit Doc

_size: number = 0

The current size of this map.

buckets: [K, V][][]

The buckets for storing key/value pairs. The outer array is the bucket location, with the inner array being the bucket for the entries.

Accessors

  • get size(): number
  • Inherit Doc

    Returns number

Methods

  • Inherit Doc

    Returns IterableIterator<[K, V]>

  • Inherit Doc

    Returns void

  • Inherit Doc

    Parameters

    • key: K

    Returns boolean

  • Inherit Doc

    Returns IterableIterator<[K, V]>

  • Inherit Doc

    Parameters

    • callbackFn: ((value: V, key: K, map: Map<K, V>) => void)
        • (value: V, key: K, map: Map<K, V>): void
        • Parameters

          • value: V
          • key: K
          • map: Map<K, V>

          Returns void

    • Optional thisArg: any

    Returns void

  • Inherit Doc

    Parameters

    • key: K

    Returns undefined | V

  • Returns a boolean asserting whether a value has been associated to the key in the Map object or not.

    Returns

    true if the key is currently associated with a value within the map, otherwise returns false

    Parameters

    • key: K

      the key of the element to test for presence in the Map object

    Returns boolean

  • Inherit Doc

    Returns IterableIterator<K>

  • Inherit Doc

    Parameters

    • key: K
    • value: V

    Returns HashMap<K, V>

  • Returns IterableIterator<V>