18 lines
406 B
JavaScript
18 lines
406 B
JavaScript
/* eslint-env browser */
|
|
|
|
const storage = (() => {
|
|
// return localstorage in the browser env
|
|
if (this && this.localStorage) return this.localStorage;
|
|
|
|
// return a mock localstorage in the server env
|
|
return {
|
|
getItem: () => null,
|
|
setItem: () => null,
|
|
};
|
|
})();
|
|
|
|
export default {
|
|
get: id => JSON.parse(storage.getItem(id)),
|
|
set: (id, val) => storage.setItem(id, JSON.stringify(val)),
|
|
};
|