HybridWeakMap
trait~ HybridWeakMap
Drop-in replacement for WeakMap that can store primitives.
new
const m = new HybridWeakMap([['foo', 42], ]);
Normally WeakMaps cannot store primitive values like Strings or Numbers; this is mostly an implementation detail and there still are some use cases where one would wish to store primitives in a weak map even though those primitive values won't be garbage collected.a
This is what HybridWeakMap is for: It simply contains two maps; one Weak map for objects, and one normal Map for primitives...