Skip to main content
Version: next

Class: NexoMap<Target>

Defined in: src/utils/NexoMap.ts:11

A specialized Map that holds weak references to traceable targets. This class emits events when modifications occur.

Extends

  • Map<string, WeakRef<Target>>

Type Parameters

Target extends Traceable

The type of objects stored in the map, which must be traceable.

Implements

  • NexoMap<Target>

Constructors

new NexoMap()

new NexoMap<Target>(): NexoMap<Target>

Defined in: src/utils/NexoMap.ts:29

Creates an instance of NexoMap.

Returns

NexoMap<Target>

Overrides

Map<string, WeakRef<Target>>.constructor

Properties

events

readonly events: NexoEmitter<NexoMapEvents>

Defined in: src/utils/NexoMap.ts:24

Event emitter instance for broadcasting changes to the map.

Implementation of

nx.NexoMap.events

Methods

clear()

clear(): void

Defined in: src/utils/NexoMap.ts:79

Clears all entries from the map and emits a clear event.

Returns

void

Implementation of

nx.NexoMap.clear

Overrides

Map.clear


delete()

delete(key): boolean

Defined in: src/utils/NexoMap.ts:60

Removes an entry from the map and emits a delete event.

Parameters

key

string

The key of the entry to remove.

Returns

boolean

true if the entry existed and was deleted, otherwise false.

Implementation of

nx.NexoMap.delete

Overrides

Map.delete


release()

release(): void

Defined in: src/utils/NexoMap.ts:90

Iterates over the map and removes entries whose WeakRef target has been garbage collected. Emits a release event after processing.

Returns

void

Implementation of

nx.NexoMap.release


set()

set(key, value): this

Defined in: src/utils/NexoMap.ts:41

Adds or updates an entry in the map and emits a set event.

Parameters

key

string

The key associated with the weak reference.

value

WeakRef<Target>

The WeakRef wrapping the target object.

Returns

this

The updated NexoMap instance.

Implementation of

nx.NexoMap.set

Overrides

Map.set