import { clear, createStore, del, delMany, entries as getEntries, get, getMany, keys as getKeys, set, setMany, update, values as getValues, } from 'idb-keyval'; class IdbStore { public store: ReturnType; constructor(name: string) { this.store = createStore(name, 'store'); } public set(key: string, value: any) { return set(key, value, this.store); } public setMany(entries: [string, any][]) { return setMany(entries, this.store); } public get(key: string) { return get(key, this.store); } public getMany(keys: string[]) { return getMany(keys, this.store); } public clear() { return clear(this.store); } public del(key: string) { return del(key, this.store); } public delMany(keys: string[]) { return delMany(keys, this.store); } public entries() { return getEntries(this.store); } public keys() { return getKeys(this.store); } public values() { return getValues(this.store); } public update(key: string, updater: (oldValue: T | undefined) => T) { return update(key, updater, this.store); } } export const MAIN_IDB_STORE = new IdbStore('tt-data'); export const PASSCODE_IDB_STORE = new IdbStore('tt-passcode');