UNPKG

@abstractest/localstorage

Version:
3 lines (2 loc) 1.48 kB
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(e,t,r)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var u=(e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},m=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _(t))!h.call(e,o)&&o!==r&&i(e,o,{get:()=>t[o],enumerable:!(a=p(t,o))||a.enumerable});return e};var f=e=>m(i({},"__esModule",{value:!0}),e);var c=(e,t,r)=>(d(e,typeof t!="symbol"?t+"":t,r),r);var w={};u(w,{LocalStorage:()=>s,destroy:()=>b,init:()=>y});module.exports=f(w);var s=class{constructor(t,r=new Map){c(this,"__data");this.__data=r;let a=this.constructor.prototype;t&&Object.entries(Object.getOwnPropertyDescriptors(a)).forEach(([o,{value:l}])=>{typeof l=="function"&&o!=="constructor"&&(this[o]=t.fn(function(...g){return a[o].call(this,...g)}))})}getItem(t){return this.__data.has(t)?this.__data.get(t):null}setItem(t,r){this.__data.set(t,r)}removeItem(t){this.__data.delete(t)}clear(){this.__data.clear()}toString(){return"[object Storage]"}key(t){return[...this.__data.keys()][t]||null}get length(){return this.__data.size}};var n=globalThis||window||global&&global.window||global,y=e=>{let t=e||n.jest;n.localStorage=new s(t),n.sessionStorage=new s(t)},b=()=>{delete n.sessionStorage,delete n.localStorage};0&&(module.exports={LocalStorage,destroy,init}); //# sourceMappingURL=index.cjs.map