nuxt-storage
Version:
🛢 Utilities for easy read and write browser's storage in Nuxt.js project
1 lines • 4.42 kB
JavaScript
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";n.d(e,"b",function(){return i}),n.d(e,"d",function(){return u}),n.d(e,"c",function(){return o}),n.d(e,"a",function(){return c});var r=function(t){return null!=t},i=function(t,e){try{var n=t.getItem(e);if(r(n)){var i=JSON.parse(n);if(r(i)){var u=(new Date).getTime(),o=i.created,c=6e4;i.unit&&"s"===i.unit?c=1e3:i.unit&&"m"===i.unit?c=6e4:i.unit&&"h"===i.unit?c=36e5:i.unit&&"d"===i.unit&&(c=864e5);var a=parseInt(i.expiry,10)*c;if(parseInt(o,10)+a>u)return i.value;console.warn("storage is expired")}}}catch(t){console.warn("failed parse JSON")}return null},u=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"m";try{var u=t,o={created:(new Date).getTime(),value:n,expiry:r,unit:i};return u.setItem(e,JSON.stringify(o)),o}catch(t){}return null},o=function(t,e){try{t.removeItem(e)}catch(t){}},c=function(t){try{t.clear()}catch(t){}}},,function(t,e,n){"use strict";n.r(e),function(t){n.d(e,"getData",function(){return u}),n.d(e,"setData",function(){return o}),n.d(e,"removeItem",function(){return c}),n.d(e,"clear",function(){return a});var r=n(0);function i(){return"sessionStorage"in window&&window.sessionStorage?window.sessionStorage:null}var u=function(e){if(t.client)try{var n=i();return Object(r.b)(n,e)}catch(t){}return null},o=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"m";if(t.client)try{var c=i();return Object(r.d)(c,e,n,u,o)}catch(t){}return null},c=function(t){try{var e=i();Object(r.c)(e,t)}catch(t){}},a=function(){try{var t=i();Object(r.a)(t)}catch(t){}}}.call(this,n(3))},function(t,e){var n,r,i=t.exports={};function u(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function c(t){if(n===setTimeout)return setTimeout(t,0);if((n===u||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:u}catch(t){n=u}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var a,l=[],f=!1,s=-1;function d(){f&&a&&(f=!1,a.length?l=a.concat(l):s=-1,l.length&&h())}function h(){if(!f){var t=c(d);f=!0;for(var e=l.length;e;){for(a=l,l=[];++s<e;)a&&a[s].run();s=-1,e=l.length}a=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function v(t,e){this.fun=t,this.array=e}function p(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];l.push(new v(t,e)),1!==l.length||f||c(h)},v.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}]);