A lightweight, zero-dependency in-memory storage implementation that mirrors the Web Storage API (localStorage/sessionStorage). Version 1.0.0 is the initial stable release, with no further updates since. It provides a simple JavaScript object-based store with methods: setItem, getItem, removeItem, clear, key, and length. Differentiates from localStorage by not persisting data, making it ideal for testing and ephemeral state in Node.js or browser environments. Includes TypeScript types.
npm install simple-memory-storageNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Instantiate SimpleMemoryStorage and use Web Storage API methods (setItem, getItem, removeItem, clear, key, length).
Create a single instance and pass it around, or use a global singleton pattern.
Always read length after calling setItem/removeItem/clear to get the current count.
Check if the returned value is null before using it as a key.
Use JSON.stringify/parse for non-string data.
Change to `import { SimpleMemoryStorage } from 'simple-memory-storage'`.Switch to ESM imports (`import { SimpleMemoryStorage } from 'simple-memory-storage'`) or use dynamic import in CommonJS.Use `storage.key(index)` instead of `storage[index]`.
No dependency data recorded yet.