-
Notifications
You must be signed in to change notification settings - Fork 62
/
immortal-db.d.ts
64 lines (53 loc) · 1.85 KB
/
immortal-db.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// ImmortalDB - A resilient key-value store for browsers.
//
// Ansgar Grunseid
// grunseid.com
//
// License: MIT
//
// TypeScript type definitions for ImmortalDB.
export interface Store {
get(key: string): Promise<string | undefined>;
set(key: string, value: string): Promise<void>;
remove(key: string): Promise<void>;
}
interface CookieAttributes {
ttl?: number | Date;
secure?: boolean;
sameSite?: 'strict' | 'Strict' | 'lax' | 'Lax' | 'none' | 'None';
}
export const DEFAULT_STORES: Store[];
export const DEFAULT_KEY_PREFIX: string;
export class CookieStore implements Store {
constructor(options?: CookieAttributes);
get(key: string): Promise<string | undefined>;
set(key: string, value: string): Promise<void>;
remove(key: string): Promise<void>;
}
export class IndexedDbStore implements Store {
constructor(dbName?: string, storeName?: string);
get(key: string): Promise<string | undefined>;
set(key: string, value: string): Promise<void>;
remove(key: string): Promise<void>;
}
declare class StorageApiWrapper implements Store {
constructor(store: Storage);
get(key: string): Promise<string | undefined>;
set(key: string, value: string): Promise<void>;
remove(key: string): Promise<void>;
}
export class LocalStorageStore extends StorageApiWrapper {}
export class SessionStorageStore extends StorageApiWrapper {}
interface StoreConstructor {
new (...args: any[]): Store;
}
export class ImmortalStorage {
constructor(stores?: StoreConstructor[]);
get(key: string, _default?: null): Promise<string | null>;
get(key: string, _default: string): Promise<string>;
set(key: string, value: string): Promise<string>;
remove(key: string): Promise<void>;
}
export const ImmortalDB: ImmortalStorage;