toWeakRef
Available since v0.7
Wraps a target object into a WeakRef
, if not already instance of a weak reference.
import { toWeakRef } from "@aedart/support/misc";
const person = { name: 'Sine' };
const a = toWeakRef(person); // new WeakRef of "person"
const b = toWeakRef(a); // same WeakRef instance as "a"
toWeakRef(null); // undefined
toWeakRef(undefined); // undefined