UNPKG

svelte-idb-store

Version:

A library that allows you to sync the value of your Svelte stores with IndexedDB

34 lines (33 loc) 1.32 kB
import { deleteDB, type IDBPDatabase } from "idb"; declare abstract class IDB<T, Key extends string> { db: IDBPDatabase; name: string; store: string; index: string; key?: Key; initialValue?: T; abstract get(): Promise<T>; abstract set(val: T): Promise<T>; private isBrowser; constructor(name: string, key?: Key, initialValue?: T, callback?: (creating: boolean) => void); open: () => Promise<boolean>; } export declare class IDBArray<T extends Record<string, any>> extends IDB<T[], Extract<keyof T, string>> { get: () => Promise<T[]>; set: (val: T[]) => Promise<T[]>; getItem: (id: string) => Promise<T>; setItem: (val: T) => Promise<T[]>; removeItem: (id: string) => Promise<T[]>; clear: () => Promise<T[]>; } export declare class IDBObject<T extends Record<string, any>> extends IDB<T, Extract<keyof T, string>> { get: () => Promise<T>; set: (val: T) => Promise<T>; getItem: <K extends Extract<keyof T, string>>(id: K) => Promise<T[K]>; setItem: <K extends Extract<keyof T, string>>(id: K, val: T[K]) => Promise<T>; removeItem: (id: Extract<keyof T, string>) => Promise<T>; clear: () => Promise<T>; } export declare const exists: (name: string) => Promise<boolean>; export declare const remove: typeof deleteDB; export {};