Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sync-idb-kvs

hoge1e3417MIT1.5.2TypeScript support: included

Synchronous IndexedDB Key-Value Store(Requires async Initialization)

IndexedDB, key-value-store

readme

sync-idb-kvs

Synchronous IndexedDB Key-Value Store(Requires async Initialization)

API

class SyncIDBStorage {
    // Create storage and fetch all data from idb to memory
    static async create(dbName = "SyncStorageDB", storeName = "kvStore"): Promise<SyncStorage>;
    // Provides localStorage-like synchronous interface
    setItem(key: string, value: string): void;
    getItem(key: string): string | null;
    removeItem(key: string): void;
    // These are slightly different from localStorage. `in` operator cannot be used.
    itemExists(key: string): boolean;
    keys(): IterableIterator<string>; 
    // When other instance(e.g. Web worker) changes the idb, this method should be called to obtain the changed data.
    reload(key:string):Promise<string|null>;
    // Number of uncommited data; if this is 0, you can close this instance safely.
    uncommited: number;
}