A minimal least-recently-used (LRU) cache implementation in about 35 lines of code, extending the native Map class. At version 1.1.0 (latest), it supports configurable max size, per-item or global maxAge for expiration, and a stale option to return expired values before deletion. Released steadily since 2017, it has zero dependencies and ships TypeScript type declarations. Compared to heavier alternatives like lru-cache, tmp-cache prioritizes simplicity and small bundle size, making it suitable for lightweight caching in Node.js (>=6) or modern browsers.
No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
ESM default export; CommonJS require returns the constructor directly, so require('tmp-cache') works without .default.
CommonJS usage via require; the module exports a single class, not a named export.
For TypeScript, you can import the class as a value or use type-only import for type annotations.
Basic LRU cache creation with max size, get, set, size, has, and expiration with stale mode.
Breaking-change detection hasn't run for this library yet.
CVE tracking and dependency tree are planned for a later release.