A zero-dependency lightweight library for iterable weak collections and proxies.
npm install @thundercraft5/weak-utilsweak-utilsweak-utils is a zero-dependency lightweight library written in TypeScript that provides weak reference utilities.
weak-utils has 3 components:
IterableWeakMap - An iterable weak map
IterableWeakSet - An iterable weak set
WeakProxy - A constructor that creates weak proxies over a target object which is weakly referenced and has support for a the standard proxy handlers and in addition to a finalizer method.
Map or WeakMap. Has all methods of Map.
Set or WeakSet. Has all methods of Set.
FinalizationRegistry(), then, when the target value is collected, the proxy is revoked.
finalize() method in the handler object.