StringCacheMap (v1.2.0) is a high-performance, LRU-based Map implementation specifically optimized for string keys, designed as a drop-in replacement for WeakMap when keys are strings. It provides a WeakMap-compatible API (set, get, has, delete) with configurable capacity limits and a victim cache for fast LRU eviction. Unlike plain objects or Map, it avoids collisions with built-in properties like 'constructor' and ensures predictable memory usage. Released on npm with a stable API, it is suitable for caching scenarios where string keys are used and memory constraints exist. It offers a 'hard' mode (default) that strictly evicts oldest entries, and a 'soft' mode that preserves recently set values.
npm install string-cache-mapNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a StringCacheMap with a capacity limit of 2, adds three entries, and demonstrates LRU eviction behavior.
Set limit to expected maximum capacity; for strict limits, use hard mode (default) and be aware of the double-buffer behavior.
Always pass strings as keys; manually convert keys with String(key) if needed.
Select appropriate mode when instantiating: new StringCacheMap(limit, hard).
Use import StringCacheMap from 'string-cache-map' (default import) instead of import { StringCacheMap } from ...Use const StringCacheMap = require('string-cache-map').default or const StringCacheMap = require('string-cache-map') if the package sets module.exports = default.Add import StringCacheMap from 'string-cache-map' at the top of the file.
No dependency data recorded yet.