@harshit-singh/local-storage-helper
v1.0.2
Published
A simple utility to safely work with localStorage
Maintainers
Readme
local-storage-helper
A simple, safe utility library to make working with localStorage easier and more predictable.
Features
- Automatically handles JSON parsing/stringifying
- Safe defaults (no crashes on missing keys)
- Clean, predictable API
- Works with arrays, objects, and primitives
- No dependencies
Installation
npm install @harshit-singh/local-storage-helperUsage
import {
set,
get,
exists,
remove,
clear,
append
} from "@harshit-singh/local-storage-helper";
// Store data
set("user", { name: "Harshit", age: 20 });
// Get data
get("user");
// → { name: "Harshit", age: 20 }
// Check if a key exists
exists("user");
// → true
// Append values
append("numbers", 1);
append("numbers", 2);
// → [1, 2]
// Remove a key
remove("user");
// Clear all localStorage
clear();