sync-idb-kvs
Version:
Synchronous IndexedDB Key-Value Store(Requires async Initialization)
29 lines (28 loc) • 1.01 kB
TypeScript
export interface IStorage {
setItem(key: string, value: string): void;
getItem(key: string): string | null;
removeItem(key: string): void;
itemExists(key: string): boolean;
keys(): IterableIterator<string>;
reload(key: string): Promise<string | null>;
}
export declare class SyncIDBStorage implements IStorage {
dbName: string;
storeName: string;
private db;
memoryCache: Record<string, string>;
uncommited: number;
static create(dbName?: string, storeName?: string): Promise<SyncIDBStorage>;
constructor(dbName?: string, storeName?: string);
private _initDB;
private _loadAllData;
getItem(key: string): string | null;
setItem(key: string, value: string): void;
removeItem(key: string): void;
itemExists(key: string): boolean;
keys(): IterableIterator<string>;
reload(key: string): Promise<string | null>;
private _getFromIndexedDB;
private _saveToIndexedDB;
private _deleteFromIndexedDB;
}