Skip to main content
The Deno 2 Release Candidate is here
Learn more

weak-value-map

A Javascript/ECMAScript map using weak references to values.

Example

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

References

License

This project is licensed under the terms of the MIT license.