Registry / testing / memoizee

memoizee

JSON →
library0.4.17jsnpmunverified

Memoizee v0.4.17 is a complete, high-performance memoization library for JavaScript, originally derived from es5-ext. It supports any type of function arguments without serialization, works with synchronous, promise-returning, and Node.js callback-style functions, and offers configurable cache strategies including LRU, timeout-based expiration, WeakMap-based garbage collection, and manual cleanup. It provides primitive mode for fast string-keyed caching, reference counter mode, and argument resolvers. Released under an ISC license with no dependencies, it has a stable, infrequent release cadence and is suitable for Node >=0.12 and browsers via bundlers. It differs from alternatives like lodash.memoize or moize in its extensive configuration options, promise support, and built-in profiling tools.

npm install memoizee
INSTALL
IMPORT
SIG · MEMOIZEE
M
memoizee
testingjavascriptv0.4.17
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

memoize (default)
import memoize from 'memoizee'
import { memoize } from 'memoizee'
Package has a default export. Named import will fail at runtime.
memoized function usage
const memoized = memoize(fn); memoized('a', 1);
const memoized = memoize(fn); memoized.call(null, 'a', 1);
Do not use .call or .apply on memoized results; it may break internal caching.
CommonJS require
const memoize = require('memoizee');
const memoize = require('memoize');
Package name is memoizee (two e's). Installing or requiring 'memoize' gives a different, unrelated package.

Shows importing memoizee, memoizing a function with a 60-second TTL, cache hit, and manual cache clearing.

import memoize from 'memoizee'; const heavyComputation = (x: number, y: number): number => { // Simulate heavy work let sum = 0; for (let i = 0; i < 1000000; i++) sum += x * y + i; return sum; }; const memoizedHeavy = memoize(heavyComputation, { maxAge: 60000 }); console.log(memoizedHeavy(5, 3)); // Computes console.log(memoizedHeavy(5, 3)); // Cache hit console.log(memoizedHeavy(5, 3)); // Cache hit (within 60s) // Clear cache manually memoizedHeavy.clear(); console.log(memoizedHeavy(5, 3)); // Computes again
Debug
Known issues
gotchaPackage name is 'memoizee' (two e's), not 'memoize'. Many developers mistakenly install 'memoize' (a different package) and wonder why options don't work.
fix
Ensure you run npm install memoizee and require/import from 'memoizee'.
affects: >=0.1.0
gotchaInvocations that throw exceptions are NOT cached. If you rely on caching of rejected promises, ensure your function does not throw synchronously.
fix
Wrap your function body to avoid synchronous throws; use async functions that return rejected promises instead.
affects: >=0.1.0
breakingAs of version 0.4.x, default export is the memoize function. CommonJS users must use require('memoizee').default? No, require returns the function directly.
fix
Use const memoize = require('memoizee'); (no .default). For ESM: import memoize from 'memoizee'.
affects: >=0.4.0
gotchaWhen using primitive mode, arguments are converted to strings via String() which can cause collisions (e.g., {a:1} becomes '[object Object]').
fix
Use normal mode (default) for non-primitive arguments, or pass custom resolvers.
affects: >=0.1.0
deprecatedThe 'profile' option is deprecated as of v0.4.0; use the separate 'memoizee-profile' module instead.
fix
Use import profile from 'memoizee/profile' or the standalone package.
affects: >=0.4.0
Errors
Common errors & fixes
Cannot find module 'memoize'
Developer installed 'memoize' instead of 'memoizee'
fix
npm uninstall memoize && npm install memoizee Then change require/import to 'memoizee'.
TypeError: memoize is not a function
Importing as named export instead of default in ESM environment
fix
Change `import { memoize } from 'memoizee'` to `import memoize from 'memoizee'`
memoized(...) is undefined
Attempting to call .clear() or other methods on the memoized function before assigning it, or using .call/.apply
fix
Ensure memoized function is correctly created: const m = memoize(fn); m('arg'); m.clear();
Error: No valid memoize configuration
Passing invalid options (e.g., typos like maxAge vs maxAge) or options object with null values
fix
Check options object: valid keys include length, maxAge, max, primitive, promise, etc.
Upgrade
Version history
0.4.17latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
memoizee — npm install memoizee · libregistry