Read a value from sessionStorage, parsing JSON when possible.
sessionStorage
Usage:
import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from "mazey";setSessionStorage("test", "123");const ret1 = getSessionStorage("test");setLocalStorage("test", "123");const ret2 = getLocalStorage("test");console.log(ret1, ret2);// Wrap the helpers with a project-specific key prefix.const projectName = "mazey";function mSetLocalStorage (key, value) { return setLocalStorage(`${projectName}_${key}`, value);}function mGetLocalStorage (key) { return getLocalStorage(`${projectName}_${key}`);} Copy
import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from "mazey";setSessionStorage("test", "123");const ret1 = getSessionStorage("test");setLocalStorage("test", "123");const ret2 = getLocalStorage("test");console.log(ret1, ret2);// Wrap the helpers with a project-specific key prefix.const projectName = "mazey";function mSetLocalStorage (key, value) { return setLocalStorage(`${projectName}_${key}`, value);}function mGetLocalStorage (key) { return getLocalStorage(`${projectName}_${key}`);}
Output:
123 123 Copy
123 123
Storage key.
The parsed value, raw stored value, or null when no value exists.
null
Read a value from
sessionStorage, parsing JSON when possible.Usage:
Output: