https://github.com/krakenjs/cross-domain-safe-weakmap
Cross-domain safe WeakMap shim
https://github.com/krakenjs/cross-domain-safe-weakmap
Last synced: 2 months ago
JSON representation
Cross-domain safe WeakMap shim
- Host: GitHub
- URL: https://github.com/krakenjs/cross-domain-safe-weakmap
- Owner: krakenjs
- License: apache-2.0
- Created: 2017-03-31T01:46:56.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2023-03-21T18:57:29.000Z (over 2 years ago)
- Last Synced: 2024-07-31T18:18:15.606Z (11 months ago)
- Language: JavaScript
- Size: 401 KB
- Stars: 33
- Watchers: 12
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
## Cross Domain Safe WeakMap
[![build status][build-badge]][build]
[![code coverage][coverage-badge]][coverage]
[![npm version][version-badge]][package]
[![apache license][license-badge]][license][build-badge]: https://img.shields.io/github/actions/workflow/status/krakenjs/cross-domain-safe-weakmap/main.yml?branch=main&logo=github&style=flat-square
[build]: https://github.com/krakenjs/cross-domain-safe-weakmap/actions/workflows/main.yml?query=workflow:build
[coverage-badge]: https://img.shields.io/codecov/c/github/krakenjs/cross-domain-safe-weakmap.svg?style=flat-square
[coverage]: https://codecov.io/github/krakenjs/cross-domain-safe-weakmap
[version-badge]: https://img.shields.io/npm/v/@krakenjs/cross-domain-safe-weakmap.svg?style=flat-square
[package]: https://www.npmjs.com/package/@krakenjs/cross-domain-safe-weakmap
[license-badge]: https://img.shields.io/npm/l/@krakenjs/cross-domain-safe-weakmap.svg?style=flat-square
[license]: https://github.com/krakenjs/cross-domain-safe-weakmap/blob/main/LICENSEWeakMap shim that works with cross-domain windows. Uses native WeakMap when available.
## Installation
As of version 2 this package will be published under the `@krakenjs` scope.
```
npm install @krakenjs/cross-domain-safe-weakmap
```### Rationale
Storing references to window objects is memory-expensive, even after those window objects have closed.
Existing WeakMap shims hang an object of the WeakMap key. This poses a problem when dealing with cross-domain windows, where setting or getting any key other than a pre-defined set of readonly values, will throw a cross-origin error.