A tiny utility (v1.2.1, stable) that attaches a cache to the global object (window/global/self) using the most discreet method available: Symbols, a non-identifier string key, and non-enumerable property descriptors. Unlike typical global singletons, it minimizes discoverability and collides with other code. Keys must be strings or symbols. No dependencies, ESM and CJS support. Ideal for internal module state sharing across environments.
npm install global-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of set, get, has, and delete on the global cache.
Ensure keys are strings or Symbols.
Use cache.delete() to clean up when needed, or rely on process restarts to reset state.
Do not store sensitive data; treat as a shared cache only.
Use Symbol-polyfilled environments for full privacy.
Persist important data to localStorage or a file.
Ensure you do 'import cache from 'global-cache'' or 'const cache = require('global-cache');'Verify key is a string/symbol and that cache.set was called before cache.get.
Use cache.set(String(key), value) or Symbol(key) as appropriate.
No dependency data recorded yet.