mostly garbage

This commit is contained in:
Jeremy Kauffman 2017-04-10 08:32:40 -04:00
parent 575db85477
commit ecf54f400b
39 changed files with 1120 additions and 1166 deletions

View file

@ -12,4 +12,20 @@ export function getLocal(key) {
*/
export function setLocal(key, value) {
localStorage.setItem(key, JSON.stringify(value));
}
/**
* Thin wrapper around localStorage.getItem(). Parses JSON and returns undefined if the value
* is not set yet.
*/
export function getSession(key) {
const itemRaw = sessionStorage.getItem(key);
return itemRaw === null ? undefined : JSON.parse(itemRaw);
}
/**
* Thin wrapper around localStorage.setItem(). Converts value to JSON.
*/
export function setSession(key, value) {
sessionStorage.setItem(key, JSON.stringify(value));
}