UNPKG

@vegajs/storage

Version:

A flexible and type-safe storage service adapter for TypeScript and JavaScript. Supports various storage mechanisms like localStorage, query strings, and mock storage with both asynchronous and synchronous APIs.

1 lines 772 B
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a={};((e,r)=>{for(var s in r)t(e,s,{get:r[s],enumerable:!0})})(a,{MockStorageService:()=>c}),module.exports=(e=a,((e,a,c,n)=>{if(a&&"object"===typeof a||"function"===typeof a)for(let g of s(a))o.call(e,g)||g===c||t(e,g,{get:()=>a[g],enumerable:!(n=r(a,g))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));class c{constructor(){this.storage=new Map}async getItem(e){return this.storage.get(e)}getItemSync(e){return this.storage.get(e)||null}async setItem(e,t){this.storage.set(e,t)}setItemSync(e,t){this.storage.set(e,t)}clearItem(e){this.storage.delete(e)}clear(){this.storage.clear()}has(e){return this.storage.has(e)}}