Registry / storage / money-clip

money-clip

JSON →
library4.0.0jsnpmunverified

Tiny wrapper over idb-keyval for client-side caching in PWAs, adding versioning and max-age support. Current stable version is 4.0.0, ESM-only. Designed to swallow errors for non-critical caching. Provides a simple cache API with get, set, del, clear, keys, getAll, getConfiguredCache, createStore, and keyValLib. Version 4.0.0 requires modern bundlers and uses ES modules.

npm install money-clip
INSTALL
IMPORT
SIG · MONEY-CLIP
M
money-clip
storagejavascriptv4.0.0
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.

getAll
import { getAll } from 'money-clip'
const { getAll } = require('money-clip')
ESM-only since v4; require() will throw an error
get
import { get } from 'money-clip'
import get from 'money-clip'
Named import, not default import
set
import { set } from 'money-clip'
import { set } from 'money-clip'
Works as a named import from the package

Shows basic usage of set(), get(), getAll() and getConfiguredCache() with versioning and max age in milliseconds.

import { get, set } from 'money-clip'; // Configure version and max age const options = { version: 1, maxAge: 3600000 }; // 1 hour // Set a value await set('key', 'value', options); // Get a value const value = await get('key', options); console.log(value); // 'value' or null if expired // Use getAll to retrieve all cached values import { getAll } from 'money-clip'; const all = await getAll(options); console.log(all); // { key: 'value', ... } // Use getConfiguredCache to pre-apply options import { getConfiguredCache } from 'money-clip'; const cache = getConfiguredCache({ version: 2, maxAge: 86400000 }); await cache.set('user', { name: 'Alice' }); const user = await cache.get('user'); console.log(user); // { name: 'Alice' }
Debug
Known issues
breakingVersion 4 drops CommonJS support and is ESM-only
fix
Use import syntax or switch to a bundler that supports ES modules
affects: >=4.0.0
gotchaAll methods swallow errors and return null or {} on failure
fix
Do not rely on error handling for caching logic; check for null or empty object
affects: *
gotchagetAll() skips keys that fail version/age checks but does not delete them
fix
If you want to clean up stale entries, consider using get() which deletes on failure
affects: *
Errors
Common errors & fixes
Cannot find module 'money-clip'
The package is not installed or the import path is incorrect
fix
Run 'npm install money-clip' and ensure you are using the correct import syntax (ESM)
ReferenceError: require is not defined
Using require() with an ESM-only version (v4+)
fix
Replace require() with import statements: import { ... } from 'money-clip'
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
idb-keyvalrequiredUnderlying IndexedDB wrapper used for all storage operations
Agent activity
20 hits · last 30 days
node
20
Resources
money-clip — npm install money-clip · libregistry