-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathstore.ts
76 lines (65 loc) · 1.88 KB
/
store.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
65
66
67
68
69
70
71
72
73
74
75
76
import { type AztecArray } from './array.js';
import { type Key } from './common.js';
import { type AztecCounter } from './counter.js';
import { type AztecMap, type AztecMultiMap } from './map.js';
import { type AztecSet } from './set.js';
import { type AztecSingleton } from './singleton.js';
/** A key-value store */
export interface AztecKVStore {
/**
* Creates a new map.
* @param name - The name of the map
* @returns The map
*/
openMap<K extends string | number, V>(name: string): AztecMap<K, V>;
/**
* Creates a new set.
* @param name - The name of the set
* @returns The set
*/
openSet<K extends string | number>(name: string): AztecSet<K>;
/**
* Creates a new multi-map.
* @param name - The name of the multi-map
* @returns The multi-map
*/
openMultiMap<K extends string | number, V>(name: string): AztecMultiMap<K, V>;
/**
* Creates a new array.
* @param name - The name of the array
* @returns The array
*/
openArray<T>(name: string): AztecArray<T>;
/**
* Creates a new singleton.
* @param name - The name of the singleton
* @returns The singleton
*/
openSingleton<T>(name: string): AztecSingleton<T>;
/**
* Creates a new count map.
* @param name - name of the counter
*/
openCounter<K extends Key>(name: string): AztecCounter<K>;
/**
* Starts a transaction. All calls to read/write data while in a transaction are queued and executed atomically.
* @param callback - The callback to execute in a transaction
*/
transaction<T extends Exclude<any, Promise<any>>>(callback: () => T): Promise<T>;
/**
* Clears all entries in the store
*/
clear(): Promise<void>;
/**
* Forks the store.
*/
fork(): Promise<AztecKVStore>;
/**
* Deletes the store
*/
delete(): Promise<void>;
/**
* Estimates the size of the store in bytes.
*/
estimateSize(): { bytes: number };
}