A TypeScript library that provides a robust abstraction over browser localStorage and sessionStorage, with automatic in-memory fallback when storage is unavailable or quota is exceeded. Version 2.1.4 (last released) is stable and maintained on GitHub. Key differentiators: seamless overflow handling, custom global storage objects that can hold non-string data (e.g., File objects), and searchable keys with StartWith/EndsWith/Includes support via the Searchable type. Lightweight (~5KB minified), no dependencies, and includes full TypeScript definitions.
npm install storage-deckNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows adding, retrieving, searching (with SearchType), removing, and clearing items using localStorage.
Import SearchType from 'storage-deck' and use SearchType.EndsWith, SearchType.Includes, or SearchType.StartsWith.
Check for null before using the result as a string.
Update calls from addToLocalStorage('key', 'value') to addToLocalStorage({ key: 'key', value: 'value' }).Design your app to handle data loss if fallback is used (e.g., re-fetch from server).
Use the appropriate function group for your storage need.
import { addToLocalStorage } from 'storage-deck';npm install storage-deck
Use { searchTerm: 'value', searchType: SearchType.Includes }.import { SearchType } from 'storage-deck';No dependency data recorded yet.