-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
150 lines (142 loc) · 8.49 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/**
* `murmurhash-native` module.
*
* Example:
*
* ```ts
* import { murmurHash128x64 } from "murmurhash-native"
*
* console.log(murmurHash128x64("hash me!", 42))
* ```
*
* @module murmurhash-native
*/
/**
* Indicates the form and encoding of the resulting hash and can be one of:
*
* - "base64" - base64 string
* - "binary" - binary string
* - "buffer" - a new Buffer object
* - "hex" - hexadecimal string
* - "number" - for 32-bit murmur hash an unsigned 32-bit integer, other hashes - hexadecimal string
*/
export type OutputType = "base64"|"binary"|"buffer"|"hex"|"number";
/**
* The expected encoding of the provided data as a string.
*/
export type Encoding = "ascii"|"base64"|"binary"|"hex"|"ucs-2"|"ucs2"|"utf-16le"|"utf-8"|"utf16le"|"utf8";
/** An interface for murmurhash functions. */
export interface MurmurHashFn {
(data: string|Buffer): number|string;
(data: string|Buffer, callback: (err: Error, res: number|string) => void): void;
(data: string|Buffer, output: Buffer, offset?: number, length?: number): Buffer;
(data: string|Buffer, output: Buffer, callback: (err: Error, res: Buffer) => void): void;
(data: string|Buffer, output: Buffer, offset: number, callback: (err: Error, res: Buffer) => void): void;
(data: string|Buffer, output: Buffer, offset: number, length: number, callback: (err: Error, res: Buffer) => void): void;
(data: string, encOrOutType: Encoding|OutputType, seed?: number): number|string|Buffer;
(data: string, encOrOutType: Encoding|OutputType, callback: (err: Error, res: number|string|Buffer) => void): void;
(data: string, encOrOutType: Encoding|OutputType, seed: number, callback: (err: Error, res: number|string|Buffer) => void): void;
(data: Buffer, outputType: OutputType, seed?: number): number|string|Buffer;
(data: Buffer, outputType: OutputType, callback: (err: Error, res: number|string|Buffer) => void): void;
(data: Buffer, outputType: OutputType, seed: number, callback: (err: Error, res: number|string|Buffer) => void): void;
(data: string|Buffer, seed: number): number|string;
(data: string|Buffer, seed: number, callback: (err: Error, res: number|string) => void): void;
(data: string|Buffer, seed: number, output: Buffer, offset?: number, length?: number): Buffer;
(data: string|Buffer, seed: number, output: Buffer, callback: (err: Error, res: Buffer) => void): void;
(data: string|Buffer, seed: number, output: Buffer, offset: number, callback: (err: Error, res: Buffer) => void): void;
(data: string|Buffer, seed: number, output: Buffer, offset: number, length: number, callback: (err: Error, res: Buffer) => void): void;
(data: string|Buffer, seed: number, outputType: OutputType): number|string|Buffer;
(data: string|Buffer, seed: number, outputType: OutputType, callback: (err: Error, res: number|string|Buffer) => void): void;
(data: string|Buffer, encoding: Encoding, outputType: OutputType): number|string|Buffer;
(data: string|Buffer, encoding: Encoding, outputType: OutputType, callback: (err: Error, res: number|string|Buffer) => void): void;
(data: string, encoding: Encoding, output: Buffer, offset?: number, length?: number): Buffer;
(data: string, encoding: Encoding, output: Buffer, callback: (err: Error, res: Buffer) => void): void;
(data: string, encoding: Encoding, output: Buffer, offset: number, callback: (err: Error, res: Buffer) => void): void;
(data: string, encoding: Encoding, output: Buffer, offset: number, length: number, callback: (err: Error, res: Buffer) => void): void;
(data: string, encoding: Encoding, seed: number): number|string;
(data: string, encoding: Encoding, seed: number, callback: (err: Error, res: number|string) => void): void;
(data: string, encoding: Encoding, seed: number, output: Buffer, offset?: number, length?: number): Buffer;
(data: string, encoding: Encoding, seed: number, output: Buffer, callback: (err: Error, res: Buffer) => void): void;
(data: string, encoding: Encoding, seed: number, output: Buffer, offset: number, callback: (err: Error, res: Buffer) => void): void;
(data: string, encoding: Encoding, seed: number, output: Buffer, offset: number, length: number, callback: (err: Error, res: Buffer) => void): void;
(data: string, encoding: Encoding, seed: number, outputType: OutputType): number|string|Buffer;
(data: string, encoding: Encoding, seed: number, outputType: OutputType, callback: (err: Error, res: number|string|Buffer) => void): void;
}
/**
* An interface for murmurhash 32-bit functions.
*
* Functions of this type produce hashes as an unsigned 32-bit integers by default
* and for the "number" output type.
*/
export interface MurmurHashFnI extends MurmurHashFn {
(data: string|Buffer): number;
(data: string|Buffer, callback: (err: Error, res: number) => void): void;
(data: string|Buffer, seed: number): number;
(data: string|Buffer, seed: number, callback: (err: Error, res: number) => void): void;
(data: string, encoding: Encoding, seed: number): number;
(data: string, encoding: Encoding, seed: number, callback: (err: Error, res: number) => void): void;
}
/**
* An interface for murmurhash 64/128-bit functions.
*
* Functions of this type produce hashes as a hexadecimal string by default
* and for the "number" output type.
*/
export interface MurmurHashFnH extends MurmurHashFn {
(data: string|Buffer): string;
(data: string|Buffer, callback: (err: Error, res: string) => void): void;
(data: string, encOrOutType: Encoding|OutputType, seed?: number): string|Buffer;
(data: string, encOrOutType: Encoding|OutputType, callback: (err: Error, res: string|Buffer) => void): void;
(data: string, encOrOutType: Encoding|OutputType, seed: number, callback: (err: Error, res: string|Buffer) => void): void;
(data: Buffer, outputType: OutputType, seed?: number): string|Buffer;
(data: Buffer, outputType: OutputType, callback: (err: Error, res: string|Buffer) => void): void;
(data: Buffer, outputType: OutputType, seed: number, callback: (err: Error, res: string|Buffer) => void): void;
(data: string|Buffer, seed: number): string;
(data: string|Buffer, seed: number, callback: (err: Error, res: string) => void): void;
(data: string|Buffer, seed: number, outputType: OutputType): string|Buffer;
(data: string|Buffer, seed: number, outputType: OutputType, callback: (err: Error, res: string|Buffer) => void): void;
(data: string|Buffer, encoding: Encoding, outputType: OutputType): string|Buffer;
(data: string|Buffer, encoding: Encoding, outputType: OutputType, callback: (err: Error, res: string|Buffer) => void): void;
(data: string, encoding: Encoding, seed: number): string;
(data: string, encoding: Encoding, seed: number, callback: (err: Error, res: string) => void): void;
(data: string, encoding: Encoding, seed: number, outputType: OutputType): string|Buffer;
(data: string, encoding: Encoding, seed: number, outputType: OutputType, callback: (err: Error, res: string|Buffer) => void): void;
}
export const murmurHash: MurmurHashFnI;
export const murmurHash32: MurmurHashFnI;
export const murmurHash64: MurmurHashFnH;
export const murmurHash64x64: MurmurHashFnH;
export const murmurHash64x86: MurmurHashFnH;
export const murmurHash128: MurmurHashFnH;
export const murmurHash128x64: MurmurHashFnH;
export const murmurHash128x86: MurmurHashFnH;
export namespace BE {
export const murmurHash: MurmurHashFnI;
export const murmurHash32: MurmurHashFnI;
export const murmurHash64: MurmurHashFnH;
export const murmurHash64x64: MurmurHashFnH;
export const murmurHash64x86: MurmurHashFnH;
export const murmurHash128: MurmurHashFnH;
export const murmurHash128x64: MurmurHashFnH;
export const murmurHash128x86: MurmurHashFnH;
}
export namespace LE {
export const murmurHash: MurmurHashFnI;
export const murmurHash32: MurmurHashFnI;
export const murmurHash64: MurmurHashFnH;
export const murmurHash64x64: MurmurHashFnH;
export const murmurHash64x86: MurmurHashFnH;
export const murmurHash128: MurmurHashFnH;
export const murmurHash128x64: MurmurHashFnH;
export const murmurHash128x86: MurmurHashFnH;
}
export namespace platform {
export const murmurHash: MurmurHashFnI;
export const murmurHash32: MurmurHashFnI;
export const murmurHash64: MurmurHashFnH;
export const murmurHash64x64: MurmurHashFnH;
export const murmurHash64x86: MurmurHashFnH;
export const murmurHash128: MurmurHashFnH;
export const murmurHash128x64: MurmurHashFnH;
export const murmurHash128x86: MurmurHashFnH;
}