Class XMap<K, V>

XMap is like Map, except that it supports automatically creating missing entries with sGet according to a default value getter function.

Type Parameters

  • K

    The type of the keys the map holds.

  • V

    The type of the values the map holds.

Hierarchy (View Summary)

Implements

  • Iterable<[K, V]>

Constructors

Properties

newXMapGetter: {} = newXMapGetter

Returns a function that when called returns a new XMap.

You can pass this to the constructor of an XMap or an XWeakMap, whose values are XMaps.

"[iterator]": () => IterableIterator<[K, V]>
clear: () => void

Deletes all entries in the XMap.

delete: (key: K) => void

Deletes a value at the given key in the XMap or XWeakMap.

entries: () => MapIterator<[K, V]>

Returns an iterator over the XMap entries.

get: (key: K) => undefined | V

Returns the value at the given key in the XMap or XWeakMap.

has: (key: K) => boolean

Returns true if the XMap or XWeakMap contains the given key.

keys: () => MapIterator<K>

Returns an iterator over the XMap keys.

prune: (sk: K, ...rest: unknown[]) => void

Deletes empty keys in the XMap or XWeakMap starting at the final nested path and checking the level above after deletion.

A key is considered empty if it's value is undefined or it's an empty Map, Set, Array, etc (anything with size or length property equal to 0).

set: (key: K, value: V) => void

Sets a value at the given key in the XMap or XWeakMap.

sGet: (key: K) => V

Like get except that if the key is not found in the map, then it will set and return a default value by calling getDefaultV passed to the constructor.

size: number

Returns the number of entries in the XMap.

values: () => MapIterator<V>

Returns an iterator over the XMap values.