state.js/dist/state.min.js

4 lines
849 B
JavaScript
Raw Permalink Normal View History

2019-06-24 19:45:14 +00:00
/* state.js v0.5.0 | MIT | /http://code.negative9.net/geoff/state.js */
!function(e,t){"function"==typeof define&&define.amd?define(["state"],t):"object"==typeof module&&module.exports?module.exports=t(e.state):e.state=t(e.state)}(this,function(){"use strict";return function(e){e=Object.assign({cache:!1,debug:!1},e||{});let t={};function o(...t){e.debug&&console.log(t)}return o("INIT:",t),o("DEBUG:",e.debug),o("CACHE:",e.cache),{get:o=>e.cache?function(e){return"object"!=typeof e||null===e?e||!1:"object"==typeof e?"undefined"!==e.length?!!e.length&&e:Object.getOwnPropertyNames(e).length>0&&e:void 0}(JSON.parse(global.localStorage.getItem(o))):t[o],set:(o,n)=>(e.cache?global.localStorage.setItem(o,JSON.stringify(n)):t[o]=n,n),remove:o=>e.cache?global.localStorage.removeItem(o):t[o]=null,clear:()=>{}}}});
//# sourceMappingURL=state.js.map