Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "mini-stash", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "ES browser storage helper", | ||
@@ -5,0 +5,0 @@ "author": "Dean Verleger", |
@@ -40,25 +40,35 @@ # mini-stash | ||
const data = { | ||
latitude: 33.441792, | ||
longitude: -94.037689 | ||
}; | ||
// it's a good idea to prefix storage keys | ||
const storageKey = 'myapp-coords'; | ||
// save to local storage | ||
stash(storageKey, data); | ||
// save to session storage | ||
stash(data, false); | ||
stash(storageKey, data, false); | ||
// retrieve from local storage (discard if data is older than a day) | ||
// retrieve from local storage (discard if older than a day) | ||
let coords = retrieve(storageKey, 60 * 24); | ||
if (!coords) { | ||
// ... get the coords | ||
coords = { | ||
latitude: 33.441792, | ||
longitude: -94.037689 | ||
}; | ||
// save to local storage | ||
stash(storageKey, coords); | ||
} | ||
// retrieve from session storage (disable cache) | ||
let sessionCoords = retrieve(storageKey, 0, true); | ||
// retrieve from session storage (disable expiration) | ||
const loginStorageKey = 'myapp-login'; | ||
let loginData = retrieve(loginStorageKey, 0, true); | ||
if (!loginData) { | ||
// ... get login data | ||
loginData = { | ||
uid: 021947 | ||
}; | ||
// save to session storage | ||
stash(loginStorageKey, loginData, true); | ||
} | ||
// clear from local storage | ||
@@ -68,3 +78,3 @@ clear(storageKey); | ||
// clear from session storage | ||
clear(storageKey, true); | ||
clear(loginStorageKey, true); | ||
``` | ||
@@ -71,0 +81,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168996
98