cache-ts v1.0.0 is a lightweight, TypeScript-native cache implementation that extends the built-in Map class with automatic capacity control and LRU-like eviction. It provides a simple constructor taking a maximum capacity, and standard set/get operations that promote recently accessed entries. Unlike heavier caching libraries, it has zero dependencies and ships inline TypeScript declarations. Currently stable with low release cadence; suitable for small to medium caching needs where simplicity and type safety are prioritized over advanced features like TTL or persistence.
npm install cache-tsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates cache creation, setting entries, access-triggered promotion, and automatic eviction when capacity is exceeded.
Use cache.has(key) to check existence before .get() if you need to distinguish missing from undefined values.
Iterate using cache.entries() or cache.keys() which return entries in insertion order (not access order).
Ensure capacity is a positive integer when constructing: new Cache(Math.max(1, Math.floor(capacity)))
Use named import: import { Cache } from 'cache-ts'Provide a valid number: new Cache(100)
Use destructuring: const { Cache } = require('cache-ts')No dependency data recorded yet.