storage-helpers
v0.5.0
Published
## Description
Downloads
2
Maintainers
Readme
storage-helpers —
Description
A set of tools to manage localStorage, sessionStorage and more that run on browsers, node and deno.
Main features
tiny, less than 1kB, and tree-shakable.
optional storage key versioning and namespace.
optional custom serialization and hydration logic.
optional validation of hydrated data.
Simple example
const storageConfig = {
version: "v2",
namespace: "user-conf"
};
// persists on localStorage `[user-conf]i18n@v2` -> `{"locale":"es-ES","floatingPoint":"dot","unit":"metric"}`
setStorageItem("i18n", { locale: 'es-ES', floatingPoint: 'dot', unit: 'metric' }, storageConfig);
// returns `{"locale":"es-ES","floatingPoint":"dot","unit":"metric"}` hydrated
getStorageItem("i18n", storageConfig);
Installation
node
Add storage-helpers to package.json
npm i storage-helpers --save
deno
Import directly in your typescript files
import { setStorageItem } "https://deno.land/x/[email protected]/mod.ts";
UMD build
html files
<script src="https://unpkg.com/[email protected]/dist/storage_helpers.umd.production.min.js"></script>
Documentation
- Storage helpers docs (github.com)
- Storage helpers docs (doc.deno.land)
- npm page
- deno.land page
- Changelog