1.2.1 • Published 2 years ago
storage-save v1.2.1
A package to work with local and session storage on the browser
npm i storage-save
and import one of the storage options (locale or session)
how to work with storage
import { localeStorage } from 'storage-save'
orimport { sessionStorage } from 'storage-save'
there are 3 methods for both
1. get
to get data from storage
localeStorage.get("key")
sessionStorage.get("key")
if you want to get data without parsing, pass the second argument false
(default true)
localeStorage.get("key", false) sessionStorage.get("key", false)
2. set
to set data to storage
localeStorage.set("key", data)
sessionStorage.set("key", data)
if you want the method to stringify data, pass true as the third argument
(deault false)
localeStorage.get("key", data, true) sessionStorage.get("key", data, true)
3. remove
to remove data from storage
localeStorage.remove("key")
sessionStorage.remove("key")
if you want the method to return data before being deleted, pass true as the second argument
(default false)
localeStorage.remove("key", true) sessionStorage.remove("key", true)