gossamer/weak_map
Types
A JS WeakMap whose keys are weakly held — entries are eligible for
GC once the key has no other references. Mutable.
Keys must be objects (records, lists, tuples) or non-registered
symbols (gossamer/symbol.new, not gossamer/symbol.for); set
and from_list return an error otherwise. Has no size, iteration,
or clear (those would expose GC timing).
Keys are matched by JS reference identity, not value equality — two equal-by-value tuples constructed separately are distinct keys.
See WeakMap on MDN.
pub type WeakMap(key, value)
Values
pub fn delete(
from map: WeakMap(key, value),
key key: key,
) -> WeakMap(key, value)
Mutates the map.
pub fn from_list(
entries: List(#(key, value)),
) -> Result(WeakMap(key, value), js_error.JsError)
Returns an error if any key in entries is invalid.
pub fn get(
from map: WeakMap(key, value),
key key: key,
) -> Result(value, Nil)
Returns the value associated with the given key, or an error if not found.
pub fn set(
in map: WeakMap(key, value),
key key: key,
value value: value,
) -> Result(WeakMap(key, value), js_error.JsError)
Mutates the map. Returns an error if key is invalid.