k2hash 1.1.33 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +106 -0
- package/build/cjs/index.js +296 -0
- package/build/esm/index.js +293 -0
- package/buildutils/make_node_prebuild_variables.sh +359 -0
- package/buildutils/node_prebuild.sh +371 -0
- package/buildutils/node_prebuild_install.sh +307 -0
- package/index.js +4 -1
- package/index.mjs +154 -0
- package/package.json +76 -20
- package/src/index.ts +378 -0
- package/src/k2h_cbs.cc +27 -41
- package/src/k2h_cbs.h +17 -13
- package/src/k2h_common.h +1 -1
- package/src/k2h_keyqueue.cc +513 -339
- package/src/k2h_keyqueue.h +38 -30
- package/src/k2h_keyqueue_async.h +222 -184
- package/src/k2h_queue.cc +483 -304
- package/src/k2h_queue.h +38 -30
- package/src/k2h_queue_async.h +218 -173
- package/src/k2h_shm.cc +1963 -1221
- package/src/k2h_shm.h +109 -104
- package/src/k2h_shm_async.h +722 -560
- package/src/k2hash.cc +22 -8
- package/src/k2hkeyqueue.cc +21 -8
- package/src/k2hqueue.cc +21 -8
- package/types/index.d.ts +570 -0
- package/ChangeLog +0 -131
- package/src/binding.gyp +0 -146
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* K2HASH
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2015 Yahoo Japan Corporation.
|
|
5
|
+
*
|
|
6
|
+
* K2HASH is key-valuew store base libraries.
|
|
7
|
+
* K2HASH is made for the purpose of the construction of
|
|
8
|
+
* original KVS system and the offer of the library.
|
|
9
|
+
* The characteristic is this KVS library which Key can
|
|
10
|
+
* layer. And can support multi-processing and multi-thread,
|
|
11
|
+
* and is provided safely as available KVS.
|
|
12
|
+
*
|
|
13
|
+
* For the full copyright and license information, please view
|
|
14
|
+
* the license file that was distributed with this source code.
|
|
15
|
+
*
|
|
16
|
+
* AUTHOR: Takeshi Nakatani
|
|
17
|
+
* CREATE: Wed 19 Nov 2025
|
|
18
|
+
* REVISION:
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
//-------------------------------------------------------------
|
|
22
|
+
// This uses 'export' to be compatible with CommonJS consumers:
|
|
23
|
+
// const k2hash = require('k2hash');
|
|
24
|
+
//
|
|
25
|
+
// And works for ESM consumers with default import:
|
|
26
|
+
// import k2hash from 'k2hash';
|
|
27
|
+
//-------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
//
|
|
30
|
+
// callable / constructible main factory
|
|
31
|
+
//
|
|
32
|
+
declare function k2hash(): k2hash.K2hNode;
|
|
33
|
+
|
|
34
|
+
declare namespace k2hash
|
|
35
|
+
{
|
|
36
|
+
//---------------------------------------------------------
|
|
37
|
+
// Callback types for K2hNode
|
|
38
|
+
//---------------------------------------------------------
|
|
39
|
+
// [NOTE]
|
|
40
|
+
// We allow Error in case it might be changed to an Error object
|
|
41
|
+
// in the future, but currently we do not return Error.
|
|
42
|
+
//
|
|
43
|
+
export type K2hCreateCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
44
|
+
export type K2hOpenCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
45
|
+
export type K2hOpenRWCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
46
|
+
export type K2hOpenROCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
47
|
+
export type K2hOpenTempfileCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
48
|
+
export type K2hOpenMemCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
49
|
+
export type K2hCloseCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
50
|
+
export type K2hGetValueCallback = (err?: string | null, result?: string | null) => void;
|
|
51
|
+
export type K2hGetSubkeysCallback = (err?: string | null, subkeys?: string[] | null) => void;
|
|
52
|
+
export type K2hSetValueCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
53
|
+
export type K2hAddSubkeyCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
54
|
+
export type K2hAddSubkeysCallback = (err: Error | string | null, result?: boolean) => void;
|
|
55
|
+
export type K2hRemoveCallback = (err: Error | string | null, result?: boolean) => void;
|
|
56
|
+
export type K2hRemoveAllCallback = (err: Error | string | null, result?: boolean) => void;
|
|
57
|
+
export type K2hLoadArchiveCallback = (err: Error | string | null, result?: boolean) => void;
|
|
58
|
+
export type K2hPutArchiveCallback = (err: Error | string | null, result?: boolean) => void;
|
|
59
|
+
export type K2hGetAttrsCallback = (err?: Error | string | null, attrs?: string[] | null) => void;
|
|
60
|
+
export type K2hGetAttrValueCallback = (err?: Error | string | null, value?: string | null) => void;
|
|
61
|
+
export type K2hAddAttrCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
62
|
+
|
|
63
|
+
//---------------------------------------------------------
|
|
64
|
+
// Emitter callback types for K2hNode
|
|
65
|
+
//---------------------------------------------------------
|
|
66
|
+
export type OnK2hEmitterCallback = (err?: string | null, ...args: any[]) => void;
|
|
67
|
+
export type OnK2hCreateEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
68
|
+
export type OnK2hOpenEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
69
|
+
export type OnK2hOpenRWEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
70
|
+
export type OnK2hOpenROEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
71
|
+
export type OnK2hOpenTempfileEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
72
|
+
export type OnK2hOpenMemEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
73
|
+
export type OnK2hCloseEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
74
|
+
export type OnK2hGetEmitterCallback = (err?: string | null, result?: string | null) => void;
|
|
75
|
+
export type OnK2hGetSubkeysEmitterCallback = (err?: string | null, result?: string[] | null) => void;
|
|
76
|
+
export type OnK2hSetEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
77
|
+
export type OnK2hAddSubkeyEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
78
|
+
export type OnK2hAddSubkeysEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
79
|
+
export type OnK2hRemoveEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
80
|
+
export type OnK2hRemoveAllEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
81
|
+
export type OnK2hLoadEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
82
|
+
export type OnK2hLoadArchiveEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
83
|
+
export type OnK2hPutEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
84
|
+
export type OnK2hPutArchiveEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
85
|
+
export type OnK2hGetAttrsEmitterCallback = (err?: string | null, attrs?: string[] | null) => void;
|
|
86
|
+
export type OnK2hGetAttrValueEmitterCallback = (err?: string | null, value?: string | null) => void;
|
|
87
|
+
export type OnK2hAddAttrEmitterCallback = (err?: string | null, result?: boolean) => void;
|
|
88
|
+
|
|
89
|
+
//---------------------------------------------------------
|
|
90
|
+
// K2hNode Class
|
|
91
|
+
//---------------------------------------------------------
|
|
92
|
+
export class K2hNode
|
|
93
|
+
{
|
|
94
|
+
// Constructor
|
|
95
|
+
constructor(); // always no arguments
|
|
96
|
+
|
|
97
|
+
//-----------------------------------------------------
|
|
98
|
+
// Methods (Callback can be called)
|
|
99
|
+
//-----------------------------------------------------
|
|
100
|
+
// create
|
|
101
|
+
create(filename: string, cb?: K2hCreateCallback): boolean;
|
|
102
|
+
create(filename: string, isfullmapping: boolean, cb?: K2hCreateCallback): boolean;
|
|
103
|
+
create(filename: string, isfullmapping: boolean, mask_bitcnt: number, cb?: K2hCreateCallback): boolean;
|
|
104
|
+
create(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, cb?: K2hCreateCallback): boolean;
|
|
105
|
+
create(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, cb?: K2hCreateCallback): boolean;
|
|
106
|
+
create(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, pagesize: number, cb?: K2hCreateCallback): boolean;
|
|
107
|
+
|
|
108
|
+
// open
|
|
109
|
+
open(filename: string, cb?: K2hOpenCallback): boolean;
|
|
110
|
+
open(filename: string, isreadonly: boolean, cb?: K2hOpenCallback): boolean;
|
|
111
|
+
open(filename: string, isreadonly: boolean, istempfile: boolean, cb?: K2hOpenCallback): boolean;
|
|
112
|
+
open(filename: string, isreadonly: boolean, istempfile: boolean, isfullmapping: boolean, cb?: K2hOpenCallback): boolean;
|
|
113
|
+
open(filename: string, isreadonly: boolean, istempfile: boolean, isfullmapping: boolean, mask_bitcnt: number, cb?: K2hOpenCallback): boolean;
|
|
114
|
+
open(filename: string, isreadonly: boolean, istempfile: boolean, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, cb?: K2hOpenCallback): boolean;
|
|
115
|
+
open(filename: string, isreadonly: boolean, istempfile: boolean, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, cb?: K2hOpenCallback): boolean;
|
|
116
|
+
open(filename: string, isreadonly: boolean, istempfile: boolean, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, pagesize: number, cb?: K2hOpenCallback): boolean;
|
|
117
|
+
|
|
118
|
+
openRW(filename: string, cb?: K2hOpenRWCallback): boolean;
|
|
119
|
+
openRW(filename: string, isfullmapping: boolean, cb?: K2hOpenRWCallback): boolean;
|
|
120
|
+
openRW(filename: string, isfullmapping: boolean, mask_bitcnt: number, cb?: K2hOpenRWCallback): boolean;
|
|
121
|
+
openRW(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, cb?: K2hOpenRWCallback): boolean;
|
|
122
|
+
openRW(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, cb?: K2hOpenRWCallback): boolean;
|
|
123
|
+
openRW(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, pagesize: number, cb?: K2hOpenRWCallback): boolean;
|
|
124
|
+
|
|
125
|
+
openRO(filename: string, cb?: K2hOpenROCallback): boolean;
|
|
126
|
+
openRO(filename: string, isfullmapping: boolean, cb?: K2hOpenROCallback): boolean;
|
|
127
|
+
openRO(filename: string, isfullmapping: boolean, mask_bitcnt: number, cb?: K2hOpenROCallback): boolean;
|
|
128
|
+
openRO(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, cb?: K2hOpenROCallback): boolean;
|
|
129
|
+
openRO(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, cb?: K2hOpenROCallback): boolean;
|
|
130
|
+
openRO(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, pagesize: number, cb?: K2hOpenROCallback): boolean;
|
|
131
|
+
|
|
132
|
+
openTempfile(filename: string, cb?: K2hOpenTempfileCallback): boolean;
|
|
133
|
+
openTempfile(filename: string, isfullmapping: boolean, cb?: K2hOpenTempfileCallback): boolean;
|
|
134
|
+
openTempfile(filename: string, isfullmapping: boolean, mask_bitcnt: number, cb?: K2hOpenTempfileCallback): boolean;
|
|
135
|
+
openTempfile(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, cb?: K2hOpenTempfileCallback): boolean;
|
|
136
|
+
openTempfile(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, cb?: K2hOpenTempfileCallback): boolean;
|
|
137
|
+
openTempfile(filename: string, isfullmapping: boolean, mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, pagesize: number, cb?: K2hOpenTempfileCallback): boolean;
|
|
138
|
+
|
|
139
|
+
openMem(cb?: K2hOpenMemCallback): boolean;
|
|
140
|
+
openMem(mask_bitcnt: number, cb?: K2hOpenMemCallback): boolean;
|
|
141
|
+
openMem(mask_bitcnt: number, cmask_bitcnt: number, cb?: K2hOpenMemCallback): boolean;
|
|
142
|
+
openMem(mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, cb?: K2hOpenMemCallback): boolean;
|
|
143
|
+
openMem(mask_bitcnt: number, cmask_bitcnt: number, max_element_cnt: number, pagesize: number, cb?: K2hOpenMemCallback): boolean;
|
|
144
|
+
|
|
145
|
+
// close
|
|
146
|
+
close(cb?: K2hCloseCallback): boolean;
|
|
147
|
+
|
|
148
|
+
// values
|
|
149
|
+
getValue(key: string): string | null | undefined;
|
|
150
|
+
getValue(key: string, cb: K2hGetValueCallback): boolean;
|
|
151
|
+
getValue(key: string, subkey: string | null): string | null | undefined;
|
|
152
|
+
getValue(key: string, subkey: string | null, cb: K2hGetValueCallback): boolean;
|
|
153
|
+
getValue(key: string, subkey: string | null, attrchk: boolean): string | null | undefined;
|
|
154
|
+
getValue(key: string, subkey: string | null, attrchk: boolean, cb: K2hGetValueCallback): boolean;
|
|
155
|
+
getValue(key: string, subkey: string | null, attrchk: boolean, pass: string | null): string | null | undefined;
|
|
156
|
+
getValue(key: string, subkey: string | null, attrchk: boolean, pass: string | null, cb: K2hGetValueCallback): boolean;
|
|
157
|
+
|
|
158
|
+
getSubkeys(key: string): string[] | null;
|
|
159
|
+
getSubkeys(key: string, cb: K2hGetSubkeysCallback): boolean;
|
|
160
|
+
|
|
161
|
+
setValue(key: string, value: string | null, cb?: K2hSetValueCallback): boolean;
|
|
162
|
+
setValue(key: string, value: string | null, subkey: string | null, cb?: K2hSetValueCallback): boolean;
|
|
163
|
+
setValue(key: string, value: string | null, subkey: string | null, pass: string | null, cb?: K2hSetValueCallback): boolean;
|
|
164
|
+
setValue(key: string, value: string | null, subkey: string | null, pass: string | null, expire: number, cb?: K2hSetValueCallback): boolean;
|
|
165
|
+
|
|
166
|
+
addSubkey(key: string, subkey: string, cb?: K2hAddSubkeyCallback): boolean;
|
|
167
|
+
addSubkey(key: string, subkey: string, value: string | null, cb?: K2hAddSubkeyCallback): boolean;
|
|
168
|
+
|
|
169
|
+
addSubkeys(key: string, subkeys: string[], cb?: K2hAddSubkeysCallback): boolean;
|
|
170
|
+
|
|
171
|
+
remove(key: string, cb?: K2hRemoveCallback): boolean;
|
|
172
|
+
remove(key: string, subkey: string | null, cb?: K2hRemoveCallback): boolean;
|
|
173
|
+
|
|
174
|
+
removeAll(key: string, cb?: K2hRemoveCallback): boolean;
|
|
175
|
+
|
|
176
|
+
// archives
|
|
177
|
+
loadArchive(filename: string, cb?: K2hLoadArchiveCallback): boolean;
|
|
178
|
+
loadArchive(filename: string, errskip: boolean, cb?: K2hLoadArchiveCallback): boolean;
|
|
179
|
+
|
|
180
|
+
putArchive(filename: string, cb?: K2hPutArchiveCallback): boolean;
|
|
181
|
+
putArchive(filename: string, errskip: boolean, cb?: K2hPutArchiveCallback): boolean;
|
|
182
|
+
|
|
183
|
+
// attributes
|
|
184
|
+
getAttrs(key: string): string[] | null;
|
|
185
|
+
getAttrs(key: string, cb: K2hGetAttrsCallback): boolean;
|
|
186
|
+
|
|
187
|
+
getAttrValue(key: string, attr: string): string | null | undefined;
|
|
188
|
+
getAttrValue(key: string, attr: string, cb: K2hGetAttrValueCallback): boolean;
|
|
189
|
+
|
|
190
|
+
addAttr(key: string, attr: string, cb?: K2hAddAttrCallback): boolean;
|
|
191
|
+
addAttr(key: string, attr: string, value: string | null, cb?: K2hAddAttrCallback): boolean;
|
|
192
|
+
|
|
193
|
+
//-----------------------------------------------------
|
|
194
|
+
// Methods (no callback)
|
|
195
|
+
//-----------------------------------------------------
|
|
196
|
+
// states
|
|
197
|
+
printState(): string;
|
|
198
|
+
printState(fd: number): boolean;
|
|
199
|
+
|
|
200
|
+
// version
|
|
201
|
+
printVersion(fd?: number): boolean;
|
|
202
|
+
|
|
203
|
+
// dump
|
|
204
|
+
dumpHead(fd?: number): boolean;
|
|
205
|
+
dumpKeytable(fd?: number): boolean;
|
|
206
|
+
dumpFullKeytable(fd?: number): boolean;
|
|
207
|
+
dumpElementtable(fd?: number): boolean;
|
|
208
|
+
dumpFull(fd?: number): boolean;
|
|
209
|
+
|
|
210
|
+
// transaction
|
|
211
|
+
transaction(enable: boolean): boolean;
|
|
212
|
+
transaction(enable: boolean, transfile: string): boolean;
|
|
213
|
+
transaction(enable: boolean, transfile: string, prefix: string): boolean;
|
|
214
|
+
transaction(enable: boolean, transfile: string, prefix: string, param: string): boolean;
|
|
215
|
+
transaction(enable: boolean, transfile: string, prefix: string, param: string, expire: number): boolean;
|
|
216
|
+
|
|
217
|
+
enableTransaction(): boolean;
|
|
218
|
+
enableTransaction(transfile: string): boolean;
|
|
219
|
+
enableTransaction(transfile: string, prefix: string): boolean;
|
|
220
|
+
enableTransaction(transfile: string, prefix: string, param: string): boolean;
|
|
221
|
+
enableTransaction(transfile: string, prefix: string, param: string, expire: number): boolean;
|
|
222
|
+
|
|
223
|
+
disableTransaction(): boolean;
|
|
224
|
+
|
|
225
|
+
unsetTransactionThreadPool(): boolean;
|
|
226
|
+
getTransactionThreadPool(): number;
|
|
227
|
+
setTransactionThreadPool(count: number): boolean;
|
|
228
|
+
|
|
229
|
+
// k2hqueue
|
|
230
|
+
getQueue(isFifo?: boolean): K2hQueue;
|
|
231
|
+
getQueue(isFifo: boolean, prefix: string): K2hQueue;
|
|
232
|
+
|
|
233
|
+
// k2hkeyqueue
|
|
234
|
+
getKeyQueue(isFifo?: boolean): K2hKeyQueue;
|
|
235
|
+
getKeyQueue(isFifo: boolean, prefix: string): K2hKeyQueue;
|
|
236
|
+
|
|
237
|
+
// common attributes
|
|
238
|
+
setCommonAttribute(ismtime?: number): boolean;
|
|
239
|
+
setCommonAttribute(ismtime: number, ishistory: number): boolean;
|
|
240
|
+
setCommonAttribute(ismtime: number, ishistory: number, isencrypt: number): boolean;
|
|
241
|
+
setCommonAttribute(ismtime: number, ishistory: number, isencrypt: number, pass: string | null): boolean;
|
|
242
|
+
setCommonAttribute(ismtime: number, ishistory: number, isencrypt: number, pass: string | null, is_expire: number): boolean;
|
|
243
|
+
setCommonAttribute(ismtime: number, ishistory: number, isencrypt: number, pass: string | null, is_expire: number, expire: number): boolean;
|
|
244
|
+
|
|
245
|
+
cleanCommonAttribute(): boolean;
|
|
246
|
+
|
|
247
|
+
// others
|
|
248
|
+
addAttrPluginLib(libfile: string): boolean;
|
|
249
|
+
addAttrCryptPass(pass: string, isDefaultEncrypt?: boolean): boolean;
|
|
250
|
+
getAttrVersionInfos(fd?: number): boolean;
|
|
251
|
+
getAttrInfos(fd?: number): boolean;
|
|
252
|
+
|
|
253
|
+
//-----------------------------------------------------
|
|
254
|
+
// Emitter registration/unregistration
|
|
255
|
+
//-----------------------------------------------------
|
|
256
|
+
on(emitter: string, cb: OnK2hEmitterCallback): boolean;
|
|
257
|
+
onCreate(cb: OnK2hCreateEmitterCallback): boolean;
|
|
258
|
+
onOpen(cb: OnK2hOpenEmitterCallback): boolean;
|
|
259
|
+
onOpenRW(cb: OnK2hOpenRWEmitterCallback): boolean;
|
|
260
|
+
onOpenRO(cb: OnK2hOpenROEmitterCallback): boolean;
|
|
261
|
+
onOpenTempfile(cb: OnK2hOpenTempfileEmitterCallback): boolean;
|
|
262
|
+
onOpenMem(cb: OnK2hOpenMemEmitterCallback): boolean;
|
|
263
|
+
onClose(cb: OnK2hCloseEmitterCallback): boolean;
|
|
264
|
+
onGet(cb: OnK2hGetEmitterCallback): boolean;
|
|
265
|
+
onGetSubkeys(cb: OnK2hGetSubkeysEmitterCallback): boolean;
|
|
266
|
+
onSet(cb: OnK2hSetEmitterCallback): boolean;
|
|
267
|
+
onAddSubkey(cb: OnK2hAddSubkeyEmitterCallback): boolean;
|
|
268
|
+
onAddSubkeys(cb: OnK2hAddSubkeysEmitterCallback): boolean;
|
|
269
|
+
onRemove(cb: OnK2hRemoveEmitterCallback): boolean;
|
|
270
|
+
onRemoveAll(cb: OnK2hRemoveAllEmitterCallback): boolean;
|
|
271
|
+
onLoad(cb: OnK2hLoadEmitterCallback): boolean;
|
|
272
|
+
onLoadArchive(cb: OnK2hLoadArchiveEmitterCallback): boolean;
|
|
273
|
+
onPut(cb: OnK2hPutEmitterCallback): boolean;
|
|
274
|
+
onPutArchive(cb: OnK2hPutArchiveEmitterCallback): boolean;
|
|
275
|
+
onGetAttrs(cb: OnK2hGetAttrsEmitterCallback): boolean;
|
|
276
|
+
onGetAttrValue(cb: OnK2hGetAttrValueEmitterCallback): boolean;
|
|
277
|
+
onAddAttr(cb: OnK2hAddAttrEmitterCallback): boolean;
|
|
278
|
+
|
|
279
|
+
off(emitter: string): boolean;
|
|
280
|
+
offCreate(): boolean;
|
|
281
|
+
offOpen(): boolean;
|
|
282
|
+
offOpenRW(): boolean;
|
|
283
|
+
offOpenRO(): boolean;
|
|
284
|
+
offOpenTempfile(): boolean;
|
|
285
|
+
offOpenMem(): boolean;
|
|
286
|
+
offClose(): boolean;
|
|
287
|
+
offGet(): boolean;
|
|
288
|
+
offGetSubkeys(): boolean;
|
|
289
|
+
offGetAttrs(): boolean;
|
|
290
|
+
offGetAttrValue(): boolean;
|
|
291
|
+
offSet(): boolean;
|
|
292
|
+
offAddSubkey(): boolean;
|
|
293
|
+
offAddSubkeys(): boolean;
|
|
294
|
+
offAddAttr(): boolean;
|
|
295
|
+
offRemove(): boolean;
|
|
296
|
+
offRemoveAll(): boolean;
|
|
297
|
+
offLoad(): boolean;
|
|
298
|
+
offLoadArchive(): boolean;
|
|
299
|
+
offPut(): boolean;
|
|
300
|
+
offPutArchive(): boolean;
|
|
301
|
+
|
|
302
|
+
//-----------------------------------------------------
|
|
303
|
+
// Promise APIs(Currently no imprelemnts)
|
|
304
|
+
//-----------------------------------------------------
|
|
305
|
+
// [NOTE]
|
|
306
|
+
// Although it is not currently implemented, here is an example definition:
|
|
307
|
+
//
|
|
308
|
+
// ex. addSubkeysAsync?(key: string, subkeys: string[]): Promise<boolean>;
|
|
309
|
+
//
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
//---------------------------------------------------------
|
|
313
|
+
// Callback type for K2hQueue class
|
|
314
|
+
//---------------------------------------------------------
|
|
315
|
+
// [NOTE]
|
|
316
|
+
// We allow Error in case it might be changed to an Error object
|
|
317
|
+
// in the future, but currently we do not return Error.
|
|
318
|
+
//
|
|
319
|
+
export type K2hqCountCallback = (err?: Error | string | null, result?: number) => void;
|
|
320
|
+
export type K2hqPushCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
321
|
+
export type K2hqPopCallback = (err?: Error | string | null, data?: string | null) => void;
|
|
322
|
+
export type K2hqReadCallback = (err?: Error | string | null, data?: string | null) => void;
|
|
323
|
+
export type K2hqRemoveCallback = (err?: Error | string | null, result?: number) => void;
|
|
324
|
+
|
|
325
|
+
//---------------------------------------------------------
|
|
326
|
+
// Emitter Callbask functions for K2hQueue class
|
|
327
|
+
//---------------------------------------------------------
|
|
328
|
+
export type OnK2hqEmitterCallback = (err?: string | null, ...args: any[]) => void;
|
|
329
|
+
export type OnK2hqCountCallback = (err?: string | null, result?: number) => void;
|
|
330
|
+
export type OnK2hqPushCallback = (err?: string | null, result?: boolean) => void;
|
|
331
|
+
export type OnK2hqPopCallback = (err?: string | null, data?: string | null) => void;
|
|
332
|
+
export type OnK2hqReadCallback = (err?: string | null, data?: string | null) => void;
|
|
333
|
+
export type OnK2hqRemoveCallback = (err?: string | null, result?: number) => void;
|
|
334
|
+
|
|
335
|
+
//---------------------------------------------------------
|
|
336
|
+
// K2hQueue Class
|
|
337
|
+
//---------------------------------------------------------
|
|
338
|
+
export class K2hQueue
|
|
339
|
+
{
|
|
340
|
+
// Constructor
|
|
341
|
+
constructor(); // always no arguments
|
|
342
|
+
|
|
343
|
+
//-----------------------------------------------------
|
|
344
|
+
// Methods (Callback can be called)
|
|
345
|
+
//-----------------------------------------------------
|
|
346
|
+
// count
|
|
347
|
+
count(): number;
|
|
348
|
+
count(cb: K2hqCountCallback): boolean;
|
|
349
|
+
|
|
350
|
+
// push
|
|
351
|
+
push(data: string, cb?: K2hqPushCallback): boolean;
|
|
352
|
+
push(data: string, pass: string, cb?: K2hqPushCallback): boolean;
|
|
353
|
+
push(data: string, pass: string, expire: number, cb?: K2hqPushCallback): boolean;
|
|
354
|
+
|
|
355
|
+
// pop
|
|
356
|
+
pop(): string | null;
|
|
357
|
+
pop(cb: OnK2hqPopCallback): boolean;
|
|
358
|
+
pop(pass: string): string | null;
|
|
359
|
+
pop(pass: string, cb: OnK2hqPopCallback): boolean;
|
|
360
|
+
|
|
361
|
+
// read
|
|
362
|
+
read(): string | null;
|
|
363
|
+
read(cb: K2hqReadCallback): boolean;
|
|
364
|
+
read(pos: number): string | null;
|
|
365
|
+
read(pos: number, cb: K2hqReadCallback): boolean;
|
|
366
|
+
read(pos: number, pass: string): string | null;
|
|
367
|
+
read(pos: number, pass: string, cb: K2hqReadCallback): boolean;
|
|
368
|
+
|
|
369
|
+
// remove
|
|
370
|
+
remove(count: number): number;
|
|
371
|
+
remove(count: number, cb: OnK2hqRemoveCallback): boolean;
|
|
372
|
+
remove(count: number, pass: string): number;
|
|
373
|
+
remove(count: number, pass: string, cb: OnK2hqRemoveCallback): boolean;
|
|
374
|
+
|
|
375
|
+
//-----------------------------------------------------
|
|
376
|
+
// Methods (no callback)
|
|
377
|
+
//-----------------------------------------------------
|
|
378
|
+
// init(initialize)
|
|
379
|
+
init(k2hnode: K2hNode, isFifo?: boolean): boolean;
|
|
380
|
+
init(k2hnode: K2hNode, isFifo: boolean, prefix?: string): boolean;
|
|
381
|
+
|
|
382
|
+
isEmpty(): boolean;
|
|
383
|
+
dump(fd?: number): boolean;
|
|
384
|
+
|
|
385
|
+
//-----------------------------------------------------
|
|
386
|
+
// Emitter registration/unregistration
|
|
387
|
+
//-----------------------------------------------------
|
|
388
|
+
on(emitter: string, cb: OnK2hqEmitterCallback): boolean;
|
|
389
|
+
onCount(cb: OnK2hqCountCallback): boolean;
|
|
390
|
+
onPush(cb: OnK2hqPushCallback): boolean;
|
|
391
|
+
onPop(cb: OnK2hqPopCallback): boolean;
|
|
392
|
+
onRead(cb: OnK2hqReadCallback): boolean;
|
|
393
|
+
onRemove(cb: OnK2hqRemoveCallback): boolean;
|
|
394
|
+
|
|
395
|
+
off(emitter: string): boolean;
|
|
396
|
+
offCount(): boolean;
|
|
397
|
+
offPush(): boolean;
|
|
398
|
+
offPop(): boolean;
|
|
399
|
+
offRead(): boolean;
|
|
400
|
+
offRemove(): boolean;
|
|
401
|
+
|
|
402
|
+
//-----------------------------------------------------
|
|
403
|
+
// Promise APIs(Currently no imprelemnts)
|
|
404
|
+
//-----------------------------------------------------
|
|
405
|
+
// [NOTE]
|
|
406
|
+
// Although it is not currently implemented, here is an example definition:
|
|
407
|
+
//
|
|
408
|
+
// ex. addSubkeysAsync?(key: string, subkeys: string[]): Promise<boolean>;
|
|
409
|
+
//
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
//---------------------------------------------------------
|
|
413
|
+
// Callback type for K2hKeyQueue class
|
|
414
|
+
//---------------------------------------------------------
|
|
415
|
+
// [NOTE]
|
|
416
|
+
// We allow Error in case it might be changed to an Error object
|
|
417
|
+
// in the future, but currently we do not return Error.
|
|
418
|
+
//
|
|
419
|
+
export type K2hkqCountCallback = (err?: Error | string | null, result?: number) => void;
|
|
420
|
+
export type K2hkqPushCallback = (err?: Error | string | null, result?: boolean) => void;
|
|
421
|
+
export type K2hkqPopCallback = (err?: Error | string | null, data?: [string, string] | null) => void;
|
|
422
|
+
export type K2hkqReadCallback = (err?: Error | string | null, data?: [string, string] | null) => void;
|
|
423
|
+
export type K2hkqRemoveCallback = (err?: Error | string | null, result?: number) => void;
|
|
424
|
+
|
|
425
|
+
//---------------------------------------------------------
|
|
426
|
+
// Emitter Callbask functions for K2hKeyQueue class
|
|
427
|
+
//---------------------------------------------------------
|
|
428
|
+
export type OnK2hkqEmitterCallback = (err?: string | null, ...args: any[]) => void;
|
|
429
|
+
export type OnK2hkqCountCallback = (err?: string | null, result?: number) => void;
|
|
430
|
+
export type OnK2hkqPushCallback = (err?: string | null, result?: boolean) => void;
|
|
431
|
+
export type OnK2hkqPopCallback = (err?: string | null, data?: [string, string] | null) => void;
|
|
432
|
+
export type OnK2hkqReadCallback = (err?: string | null, data?: [string, string] | null) => void;
|
|
433
|
+
export type OnK2hkqRemoveCallback = (err?: string | null, result?: number) => void;
|
|
434
|
+
|
|
435
|
+
//---------------------------------------------------------
|
|
436
|
+
// K2hKeyQueue Class
|
|
437
|
+
//---------------------------------------------------------
|
|
438
|
+
export class K2hKeyQueue
|
|
439
|
+
{
|
|
440
|
+
// Constructor
|
|
441
|
+
constructor(); // always no arguments
|
|
442
|
+
|
|
443
|
+
//-----------------------------------------------------
|
|
444
|
+
// Methods (Callback can be called)
|
|
445
|
+
//-----------------------------------------------------
|
|
446
|
+
// count
|
|
447
|
+
count(): number;
|
|
448
|
+
count(cb: K2hkqCountCallback): boolean;
|
|
449
|
+
|
|
450
|
+
// push
|
|
451
|
+
push(data: string, val: string, cb?: K2hkqPushCallback): boolean;
|
|
452
|
+
push(data: string, val: string, pass: string, cb?: K2hkqPushCallback): boolean;
|
|
453
|
+
push(data: string, val: string, pass: string, expire: number, cb?: K2hkqPushCallback): boolean;
|
|
454
|
+
|
|
455
|
+
// pop
|
|
456
|
+
pop(): [string, string] | null;
|
|
457
|
+
pop(cb: OnK2hkqReadCallback): boolean;
|
|
458
|
+
pop(pass: string): [string, string] | null;
|
|
459
|
+
pop(pass: string, cb: OnK2hkqReadCallback): boolean;
|
|
460
|
+
|
|
461
|
+
// read
|
|
462
|
+
read(): [string, string] | null;
|
|
463
|
+
read(cb: OnK2hkqReadCallback): boolean;
|
|
464
|
+
read(pos: number | string): [string, string] | null;
|
|
465
|
+
read(pos: number | string, cb: OnK2hkqReadCallback): boolean;
|
|
466
|
+
read(pos: number | string, pass: string): [string, string] | null;
|
|
467
|
+
read(pos: number | string, pass: string, cb: OnK2hkqReadCallback): boolean;
|
|
468
|
+
|
|
469
|
+
// remove
|
|
470
|
+
remove(count: number): number;
|
|
471
|
+
remove(count: number, cb: OnK2hkqRemoveCallback): boolean;
|
|
472
|
+
remove(count: number, pass: string): number;
|
|
473
|
+
remove(count: number, pass: string, cb: OnK2hkqRemoveCallback): boolean;
|
|
474
|
+
|
|
475
|
+
//-----------------------------------------------------
|
|
476
|
+
// Methods (no callback)
|
|
477
|
+
//-----------------------------------------------------
|
|
478
|
+
// init(initialize)
|
|
479
|
+
init(k2hnode: K2hNode, isFifo?: boolean): boolean;
|
|
480
|
+
init(k2hnode: K2hNode, isFifo: boolean, prefix?: string): boolean;
|
|
481
|
+
|
|
482
|
+
isEmpty(): boolean;
|
|
483
|
+
dump(fd?: number): boolean;
|
|
484
|
+
|
|
485
|
+
//-----------------------------------------------------
|
|
486
|
+
// Emitter registration/unregistration
|
|
487
|
+
//-----------------------------------------------------
|
|
488
|
+
on(emitter: string, cb: OnK2hkqEmitterCallback): boolean;
|
|
489
|
+
onCount(cb: OnK2hkqCountCallback): boolean;
|
|
490
|
+
onPush(cb: OnK2hkqPushCallback): boolean;
|
|
491
|
+
onPop(cb: OnK2hkqPopCallback): boolean;
|
|
492
|
+
onRead(cb: OnK2hkqReadCallback): boolean;
|
|
493
|
+
onRemove(cb: OnK2hkqRemoveCallback): boolean;
|
|
494
|
+
|
|
495
|
+
off(emitter: string): boolean;
|
|
496
|
+
offCount(): boolean;
|
|
497
|
+
offPush(): boolean;
|
|
498
|
+
offPop(): boolean;
|
|
499
|
+
offRead(): boolean;
|
|
500
|
+
offRemove(): boolean;
|
|
501
|
+
|
|
502
|
+
//-----------------------------------------------------
|
|
503
|
+
// Promise APIs(Currently no imprelemnts)
|
|
504
|
+
//-----------------------------------------------------
|
|
505
|
+
// [NOTE]
|
|
506
|
+
// Although it is not currently implemented, here is an example definition:
|
|
507
|
+
//
|
|
508
|
+
// ex. addSubkeysAsync?(key: string, subkeys: string[]): Promise<boolean>;
|
|
509
|
+
//
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
//---------------------------------------------------------
|
|
513
|
+
// K2hashFactoryType
|
|
514
|
+
//---------------------------------------------------------
|
|
515
|
+
export type K2hashFactoryType = {
|
|
516
|
+
(): K2hNode;
|
|
517
|
+
new(): K2hNode;
|
|
518
|
+
K2hNode: typeof K2hNode;
|
|
519
|
+
K2hQueue: typeof K2hQueue;
|
|
520
|
+
K2hKeyQueue: typeof K2hKeyQueue;
|
|
521
|
+
};
|
|
522
|
+
} // end namespace k2hash
|
|
523
|
+
|
|
524
|
+
//-------------------------------------------------------------
|
|
525
|
+
// Exports
|
|
526
|
+
//-------------------------------------------------------------
|
|
527
|
+
//
|
|
528
|
+
// UMD global name
|
|
529
|
+
//
|
|
530
|
+
export as namespace k2hash;
|
|
531
|
+
|
|
532
|
+
//
|
|
533
|
+
// CommonJS default export
|
|
534
|
+
//
|
|
535
|
+
export = k2hash;
|
|
536
|
+
|
|
537
|
+
//
|
|
538
|
+
// Ambient module
|
|
539
|
+
//
|
|
540
|
+
// For "import", "import type" users(type-only export).
|
|
541
|
+
// This provides named type exports(type-only).
|
|
542
|
+
//
|
|
543
|
+
declare module 'k2hash'
|
|
544
|
+
{
|
|
545
|
+
//
|
|
546
|
+
// Default(value-level default import with esModuleInterop)
|
|
547
|
+
//
|
|
548
|
+
const _default: typeof k2hash;
|
|
549
|
+
export default _default;
|
|
550
|
+
|
|
551
|
+
//
|
|
552
|
+
// Type named exports
|
|
553
|
+
//
|
|
554
|
+
// [NOTE]
|
|
555
|
+
// ex. "import type { K2hNode } from 'k2hash'"
|
|
556
|
+
//
|
|
557
|
+
export type K2hNode = k2hash.K2hNode;
|
|
558
|
+
export type K2hQueue = k2hash.K2hQueue;
|
|
559
|
+
export type K2hKeyQueue = k2hash.K2hKeyQueue;
|
|
560
|
+
export type K2hashFactoryType = k2hash.K2hashFactoryType;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/*
|
|
564
|
+
* Local variables:
|
|
565
|
+
* tab-width: 4
|
|
566
|
+
* c-basic-offset: 4
|
|
567
|
+
* End:
|
|
568
|
+
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
569
|
+
* vim<600: noexpandtab sw=4 ts=4
|
|
570
|
+
*/
|