Interface WeakMap<K, V>

A Map object with its __mode metamethod set to "k"

interface WeakMap<K, V> {
    clear(this): void;
    clone(this): Map<K, V>;
    delete(this, key): boolean;
    forEach(this, callbackfn): void;
    get(this, key): undefined | V;
    getOrInsert(this, key, defaultValue): V;
    getOrInsertComputed(this, key, computed): V;
    has(this, key): boolean;
    isEmpty(this): boolean;
    keys(this): K[];
    set(this, key, value): this;
    size(this): number;
    values(this): V[];
}

Type Parameters

  • K extends object
  • V

Hierarchy (view full)

Methods

  • Deletes all members of the Map

    Parameters

    Returns void

  • Deletes the given key from the Map.

    Returns a boolean indicating whether or not a value was removed.

    Parameters

    Returns boolean

  • Performs the specified action for each (element / pair of elements) in the Map

    Parameters

    • this: ReadonlyMap<K, V>
    • callbackfn: ((value, key, self) => void)

      A function that accepts up to three arguments. forEach calls the callbackfn function one time for each (element / pair of elements) in the array.

        • (value, key, self): void
        • Parameters

          • value: V
          • key: K
          • self: this

          Returns void

    Returns void

  • Returns the value associated with the given key

    Parameters

    Returns undefined | V

  • Gets or inserts a value into a map, and returns the value

    Parameters

    • this: Map<K, V>
    • key: K
    • defaultValue: V

    Returns V

  • Gets or inserts a computed value and returns the value

    If getting the default value is more costly, this may be preferable over getOrInsert

    Parameters

    • this: Map<K, V>
    • key: K
    • computed: ((key) => V)
        • (key): V
        • Parameters

          • key: K

          Returns V

    Returns V

  • Returns a boolean for whether the given key exists in the Map

    Parameters

    Returns boolean

  • Returns true if empty, otherwise false.

    Parameters

    Returns boolean

  • Returns an array of the keys in this map

    Parameters

    Returns K[]

  • Associates a key with a value which can be accessed later by Map.get

    Parameters

    Returns this

  • Returns the number of elements in the Map

    Parameters

    Returns number

  • Returns an array of the values in this map

    Parameters

    Returns V[]