-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.d.ts
108 lines (95 loc) · 3.44 KB
/
index.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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import {
AbstractLevel,
AbstractDatabaseOptions,
AbstractOpenOptions,
AbstractGetOptions,
AbstractGetManyOptions,
AbstractPutOptions,
AbstractDelOptions,
AbstractBatchOptions,
AbstractChainedBatch,
AbstractIterator,
AbstractKeyIterator,
AbstractValueIterator,
AbstractIteratorOptions,
AbstractKeyIteratorOptions,
AbstractValueIteratorOptions,
AbstractBatchOperation
} from 'abstract-level'
/**
* An {@link AbstractLevel} database for browsers, backed by [IndexedDB][1].
*
* @template KDefault The default type of keys if not overridden on operations.
* @template VDefault The default type of values if not overridden on operations.
*
* [1]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
*/
export class BrowserLevel<KDefault = string, VDefault = string>
extends AbstractLevel<Uint8Array, KDefault, VDefault> {
/**
* Database constructor.
*
* @param location The name of the [`IDBDatabase`](https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase)
* to be opened, as well as the name of the object store within that database. The name
* of the `IDBDatabase` will be prefixed with {@link DatabaseOptions.prefix}.
* @param options Options, of which some will be forwarded to {@link open}.
*/
constructor (location: string, options?: DatabaseOptions<KDefault, VDefault> | undefined)
/**
* Location that was passed to the constructor.
*/
get location (): string
/**
* Database name prefix that was passed to the constructor (as `prefix`).
*/
get namePrefix (): string
/**
* Version that was passed to the constructor.
*/
get version (): number
/**
* Delete the IndexedDB database at the given {@link location}.
*/
static destroy (location: string): Promise<void>
static destroy (location: string, prefix: string): Promise<void>
}
/**
* Options for the {@link BrowserLevel} constructor.
*/
export interface DatabaseOptions<K, V> extends AbstractDatabaseOptions<K, V> {
/**
* Prefix for the `IDBDatabase` name. Can be set to an empty string.
*
* @defaultValue `'level-js-'`
*/
prefix?: string
/**
* The version to open the `IDBDatabase` with.
*
* @defaultValue `1`
*/
version?: number | string
/**
* An {@link AbstractLevel} option that has no effect on {@link BrowserLevel}.
*/
createIfMissing?: boolean
/**
* An {@link AbstractLevel} option that has no effect on {@link BrowserLevel}.
*/
errorIfExists?: boolean
}
// Export types so that consumers don't have to guess whether they're extended
export type OpenOptions = AbstractOpenOptions
export type GetOptions<K, V> = AbstractGetOptions<K, V>
export type GetManyOptions<K, V> = AbstractGetManyOptions<K, V>
export type PutOptions<K, V> = AbstractPutOptions<K, V>
export type DelOptions<K> = AbstractDelOptions<K>
export type BatchOptions<K, V> = AbstractBatchOptions<K, V>
export type BatchOperation<TDatabase, K, V> = AbstractBatchOperation<TDatabase, K, V>
export type ChainedBatch<TDatabase, K, V> = AbstractChainedBatch<TDatabase, K, V>
export type Iterator<TDatabase, K, V> = AbstractIterator<TDatabase, K, V>
export type KeyIterator<TDatabase, K> = AbstractKeyIterator<TDatabase, K>
export type ValueIterator<TDatabase, K, V> = AbstractValueIterator<TDatabase, K, V>
export type IteratorOptions<K, V> = AbstractIteratorOptions<K, V>
export type KeyIteratorOptions<K> = AbstractKeyIteratorOptions<K>
export type ValueIteratorOptions<K, V> = AbstractValueIteratorOptions<K, V>