-
Notifications
You must be signed in to change notification settings - Fork 0
/
Storage.js
1 lines (1 loc) · 1.97 KB
/
Storage.js
1
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Storage",[],t):"object"==typeof exports?exports.Storage=t():e.Storage=t()}(window,(function(){return function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){try{return localStorage.setItem("a","a"),localStorage.removeItem("a"),!0}catch(e){return!1}}(),n=new function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.get=function(e){if(o){var r=sessionStorage.getItem(e);if(r)return r;if((r=JSON.parse(localStorage.getItem(e)))&&(new Date).getTime()<r.timestamp)return r.value;t.remove(e)}return!1},this.set=function(e,t,r){if(o)try{if(0===r)return sessionStorage.setItem(e,t),localStorage.getItem(e)&&localStorage.removeItem(e),!0;var n=60*r*1e3,a={value:t,timestamp:(new Date).getTime()+n};return localStorage.setItem(e,JSON.stringify(a)),!0}catch(e){console.error(e)}return!1},this.remove=function(e){o&&localStorage.removeItem(e)}};t.default=n}])}));