Stores a map of objects with weak references to the keys, allowing them to be garbage collected. Both keys and values can be iterated over, unlike a WeakMap.

Hierarchy

  • WeakMap
    • IterableWeakMap

Constructors

  • Parameters

    • Optional entries: Iterable<[any, any]> = []

      The initial entries.

    Returns IterableWeakMap

Properties

#refs: Set<WeakRef<any>> = ...

A set of weak refs to the map's keys, allowing enumeration.

#finalizer: FinalizationRegistry<IterableWeakMapHeldValue> = ...

A FinalizationRegistry instance to clean up the ref set when objects are garbage collected.

Methods

  • Remove a key from the map.

    Parameters

    • key: any

      The key to remove.

    Returns boolean

  • Retrieve a value from the map.

    Parameters

    • key: any

      The value's key.

    Returns any

  • Place a value in the map.

    Parameters

    • key: any

      The key.

    • value: any

      The value.

    Returns IterableWeakMap

  • Clear all values from the map.

    Returns void

  • Enumerate the entries.

    Returns Generator<[any, any], void, any>

  • Enumerate the keys.

    Returns Generator<any, void, any>

  • Enumerate the values.

    Returns Generator<any, void, any>

  • Enumerate the entries.

    Returns Generator<[any, any], void, any>

  • Clean up the corresponding ref in the set when its value is garbage collected.

    Parameters

    Returns void