WeakRef

storage/WeakMapStorage~ WeakRef

A simple reference wrapper that emulates a weak reference. We seem to have no other option, since WeakMap and WeakSet are not enumerable (so what is the point of WeakMap and WeakSet if you still need to manage the keys?!) and there is no native way to create a weak reference.

Constructor

new WeakRef(target, ttl)

Source:
Initializes the weak reference to the target reference.
Parameters:
Name Type Description
target Object The target reference that should be referenced by this weak reference.
ttl number The maximum number of milliseconds the weak reference should be kept. The reference will be discarded once ACCESSED after the specified timeout.

Members

_expiration :number

Source:
The UNIX timestamp with millisecond precision marking the moment at or after which the reference will be discarded.
Type:
  • number

(nullable) _reference :Object

Source:
The actual target reference, or null if the reference has been already discarded.
Type:
  • Object

target

Source:
Returns the target reference, provided that the target reference is still alive. Returns null if the reference has been discarded.