-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinterface.ts
48 lines (29 loc) · 1 KB
/
interface.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
import { CID } from 'multiformats/cid'
import { BlockCodec } from 'multiformats/codecs/interface'
import { MultihashHasher } from 'multiformats/hashes/interface'
export interface HashMap<V> {
readonly cid: CID
get (key: string | Uint8Array): Promise<V|void>
has (key: string | Uint8Array): Promise<boolean>
size (): Promise<number>
set (key: string | Uint8Array, value: V): Promise<void>
delete (key: string | Uint8Array): Promise<void>
values (): AsyncIterable<V>
keys (): AsyncIterable<string>
keysRaw (): AsyncIterable<Uint8Array>
entries (): AsyncIterable<[string, V]>
entriesRaw (): AsyncIterable<[Uint8Array, V]>
cids (): AsyncIterable<CID>
}
export interface CreateOptions<Codec extends number, V> {
blockCodec: BlockCodec<Codec, V>
blockHasher: MultihashHasher
hasher?: MultihashHasher
hashBytes?: number
bitWidth?: number
bucketSize?: number
}
export interface Loader {
get (cid: CID): Promise<Uint8Array>
put (cid: CID, bytes: Uint8Array): Promise<void>
}