ddan-js 3.8.5 → 3.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ interface StoreOptions {
2
+ name: string;
3
+ keyPath?: string;
4
+ autoIncrement?: boolean;
5
+ indices?: Array<{
6
+ name: string;
7
+ keyPath: string | string[];
8
+ unique?: boolean;
9
+ multiEntry?: boolean;
10
+ }>;
11
+ }
12
+ interface IDBConfig {
13
+ databaseName: string;
14
+ version?: number;
15
+ stores: StoreOptions[];
16
+ debug?: boolean;
17
+ }
18
+ interface QueryOptions {
19
+ indexName?: string;
20
+ range?: IDBKeyRange;
21
+ direction?: IDBCursorDirection;
22
+ limit?: number;
23
+ }
24
+ interface CursorResult<T> {
25
+ value: T;
26
+ cursor: IDBCursorWithValue;
27
+ continue: () => void;
28
+ advance: (count: number) => void;
29
+ }
30
+ type EventType = 'open' | 'close' | 'upgrade' | 'error';
31
+ export default class IDBStore {
32
+ static indexedDBSafe: any;
33
+ private static I;
34
+ private db;
35
+ private openPromise;
36
+ private isOpening;
37
+ private readonly name;
38
+ private readonly version;
39
+ private readonly stores;
40
+ private readonly debug;
41
+ private readonly events;
42
+ constructor(config: IDBConfig);
43
+ on(event: EventType, handler: Function): void;
44
+ private emit;
45
+ private log;
46
+ private fail;
47
+ open(): Promise<IDBDatabase | undefined>;
48
+ private handleUpgrade;
49
+ private getStore;
50
+ add<T = any>(storeName: string, data: T): Promise<IDBValidKey | undefined>;
51
+ put<T = any>(storeName: string, data: T): Promise<IDBValidKey | undefined>;
52
+ get<T = any>(storeName: string, key: IDBValidKey): Promise<T | undefined>;
53
+ delete(storeName: string, key: IDBValidKey): Promise<boolean>;
54
+ clear(storeName: string): Promise<boolean>;
55
+ getAll<T = any>(storeName: string, options?: QueryOptions): Promise<T[] | undefined>;
56
+ private batch;
57
+ addBulk<T = any>(storeName: string, items: T[]): Promise<IDBValidKey[] | undefined>;
58
+ putBulk<T = any>(storeName: string, items: T[]): Promise<IDBValidKey[] | undefined>;
59
+ iterate<T = any>(storeName: string, callback: (res: CursorResult<T>) => void, options?: QueryOptions): Promise<boolean>;
60
+ count(storeName: string, range?: IDBKeyRange): Promise<number>;
61
+ getStoreNames(): string[];
62
+ hasStore(storeName: string): boolean;
63
+ close(): void;
64
+ getInfo(): {
65
+ name: string;
66
+ version: number;
67
+ objectStores: string[];
68
+ } | undefined;
69
+ static createKeyRange(lower?: any, upper?: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange | undefined;
70
+ static exists(databaseName: string): Promise<boolean>;
71
+ static deleteDatabase(name: string): Promise<boolean>;
72
+ static getDatabases(): Promise<string[]>;
73
+ }
74
+ export {};