-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathindex.ts
More file actions
91 lines (86 loc) · 2.14 KB
/
index.ts
File metadata and controls
91 lines (86 loc) · 2.14 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* @packageDocumentation
*
* Various Datastore implementations are available.
*
* ## Implementations
*
* - Mount: [`src/mount`](src/mount.ts)
* - Keytransform: [`src/keytransform`](src/keytransform.ts)
* - Sharding: [`src/sharding`](src/sharding.ts)
* - Tiered: [`src/tiered`](src/tirered.ts)
* - Namespace: [`src/namespace`](src/namespace.ts)
* - BlackHole: [`src/black-hole`](src/black-hole.ts)
*
* @example BaseDatastore
*
* An base store is made available to make implementing your own datastore easier:
*
* ```javascript
* import { BaseDatastore } from 'datastore-core'
*
* class MyDatastore extends BaseDatastore {
* constructor () {
* super()
* }
*
* async put (key, val) {
* // your implementation here
* }
*
* async get (key) {
* // your implementation here
* }
*
* // etc...
* }
* ```
*
* See the [MemoryDatastore](./src/memory.js) for an example of how it is used.
*
* @example Wrapping Stores
*
* ```js
* import { Key } from 'interface-datastore'
* import {
* MemoryStore,
* MountStore
* } from 'datastore-core'
*
* const store = new MountStore({prefix: new Key('/a'), datastore: new MemoryStore()})
* ```
*
* @example BlackHoleDatastore
*
* A datastore that does not store any data.
*
* ```js
* import { BlackHoleDatastore } from 'datastore-core/black-hole'
*
* const store = new BlackHoleDatastore()
* ```
*/
import * as Errors from './errors.js'
import * as shard from './shard.js'
import type { Key } from 'interface-datastore'
export { BaseDatastore } from './base.js'
export { MemoryDatastore } from './memory.js'
export { KeyTransformDatastore } from './keytransform.js'
export { ShardingDatastore } from './sharding.js'
export { MountDatastore } from './mount.js'
export { TieredDatastore } from './tiered.js'
export { NamespaceDatastore } from './namespace.js'
export { TieredLimitDatastore } from './tiered-limit.js'
export { Errors }
export { shard }
export interface Shard {
name: string
param: number
readonly _padding: string
fun(s: string): string
toString(): string
}
export interface KeyTransform {
convert(key: Key): Key
invert(key: Key): Key
}