Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vicary/frail-map
A WeakMap that supports primitives.
https://github.com/vicary/frail-map
Last synced: 3 months ago
JSON representation
A WeakMap that supports primitives.
- Host: GitHub
- URL: https://github.com/vicary/frail-map
- Owner: vicary
- License: mit
- Created: 2024-04-20T07:53:37.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-05-19T15:15:03.000Z (8 months ago)
- Last Synced: 2024-09-22T03:39:12.501Z (4 months ago)
- Language: TypeScript
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# FrailMap
FrailMap is an extension of WeakMap that supports primitive values using
WeakRef. It may also set individual pairs to be strongly referenced when
specified, or when WeakRef is not available.## Usage
```ts
import { FrailMap } from "frail-map";const myMap = new FrailMap();
myMap.set("foo", "foo");
myMap.set("bar", "bar", { strong: true });console.log(myMap.get("foo")); // -> "foo"
console.log(myMap.get("bar")); // -> "bar"// ... After GC ...
console.log(myMap.get("foo")); // -> undefined
console.log(myMap.get("bar")); // -> "bar"
```## Contributing
If you find a bug or would like to suggest a new feature, please open an issue
or submit a pull request on GitHub.## License
FrailMap is licensed under the MIT License. See the LICENSE file for more
information.## Funding
If you find this project useful, please consider supporting it by donating to
the author.[![Donate](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/vicary)