A Javascript/ECMAScript map using weak references to values.
import WeakValueMap from "../weak-value-map/index.js"
const wvm = new WeakValueMap
let obj = { a: 'x' }
wvm.set(42, obj)
wvm.get(42) // #=> { a: 'x' }
obj = undefined
wvm.get(42) // #=> { a: 'x' }
// GC happens...
wvm.get(42) // #=> undefined
[...wvm.keys()].includes(42) // #=> false
- ref-most-used - LRU/LFU cache of strong object references
This project is licensed under the terms of the MIT license.