forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
levelup.d.ts
68 lines (57 loc) · 2.38 KB
/
levelup.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
// Type definitions for LevelUp
// Project: https://github.com/rvagg/node-levelup
// Definitions by: Bret Little <https://github.com/blittle>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Batch {
type: string;
key: any;
value?: any;
keyEncoding?: string;
valueEncoding?: string;
}
interface LevelUp {
open(callback ?: (error : any) => any): void;
close(callback ?: (error : any) => any): void;
put(key: any, value: any, callback ?: (error: any) => any): void;
put(key: any, value: any, options?: { sync?: boolean }, callback ?: (error: any) => any): void;
get(key: any, callback ?: (error: any, value: any) => any): void;
get(key: any, options ?: { keyEncoding?: string; fillCache?: boolean }, callback ?: (error: any, value: any) => any): void;
del(key: any, callback ?: (error: any) => any): void;
del(key: any, options ?: { keyEncoding?: string; sync?: boolean }, callback ?: (error: any) => any): void;
batch(array: Batch[], options?: { keyEncoding?: string; valueEncoding?: string; sync?: boolean }, callback?: (error?: any)=>any): void;
batch(array: Batch[], callback?: (error?: any)=>any): void;
batch():LevelUpChain;
isOpen():boolean;
isClosed():boolean;
createReadStream(options?: any): any;
createKeyStream(options?: any): any;
createValueStream(options?: any): any;
createWriteStream(options?: any): any;
destroy(location: string, callback?: Function): void;
repair(location: string, callback?: Function): void;
}
interface LevelUpChain {
put(key: any, value: any): LevelUpChain;
put(key: any, value: any, options?: { sync?: boolean }): LevelUpChain;
del(key: any): LevelUpChain;
del(key: any, options ?: { keyEncoding?: string; sync?: boolean }): LevelUpChain;
clear(): LevelUpChain;
write(callback?: (error?: any)=>any) : LevelUpChain;
}
interface levelupOptions {
createIfMissing?: boolean;
errorIfExists?: boolean;
compression?: boolean;
cacheSize?: number;
keyEncoding?: string;
valueEncoding?: string;
db?: string
}
declare module "levelup" {
function levelup(hostname: string, options?: levelupOptions): LevelUp;
export = levelup;
}
declare module "leveldown" {
export function destroy(location: string, callback?: Function): void;
export function repair(location: string, callback?: Function): void;
}