Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dgp1130/composite-weak-map
https://github.com/dgp1130/composite-weak-map
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dgp1130/composite-weak-map
- Owner: dgp1130
- License: mit
- Created: 2023-12-06T01:48:55.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-11T00:09:13.000Z (about 1 year ago)
- Last Synced: 2024-10-06T02:01:53.864Z (4 months ago)
- Language: TypeScript
- Size: 116 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `CompositeWeakMap`
`WeakMap` is an excellent tool for tracking information without leaking memory.
However `WeakMap` by itself only supports lookups using a single object
reference as a key. Sometimes it is useful to key a `WeakMap` with multiple
object references, all of which are required to read the value while still
retaining its weak memory guarantees.`CompositeWeakMap` is a weak map which takes multiple partial key objects,
combines them into a single composite key and maps that key to a value.
Everything is weakly referenced, so when any partial key is garbage collected,
any associated values are also eligible to be reclaimed.## TODO:
* `CompositeWeakSet`
* Allow `WeakMap` to accept an array, `Set`, or `Bag` and use that to determine
if order matters. Should this be a different `UnorderedCompositeWeakMap`?