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.
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
Defined in: src/utils/NexoMap.ts:24
Event emitter instance for broadcasting changes to the map.
Methods
clear()
clear():
void
Defined in: src/utils/NexoMap.ts:79
Clears all entries from the map and emits a clear
event.
Returns
void
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
.
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
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.
Overrides
Map.set