A simple memoization library wrapping a fast LRU cache (tiny-lru). Current stable version is 0.3.1. It supports memoizing both synchronous and asynchronous functions, automatic cache key generation from function arguments via JSON.stringify, configurable TTL and max cache size, and full TypeScript typings. Unlike other memoize libraries, it exposes the underlying cache for inspection and supports custom cache key resolvers. Suitable for Node.js and browsers.
npm install lru-memoriseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates memoization of a sync function with TTL and max cache size.
Provide a custom cacheKeyResolver that safely serializes arguments.
Ensure your async function never rejects, or clear the cache on rejection.
Use the `cache` option with an external LRU cache to have full control.
Use `const memoize = require('lru-memorise').default;` for CommonJS.Ensure the first argument is a function (async or sync).
Always pass an object (possibly empty) as options: `memoize(fn, {})`.