@dra2020/baseclient 1.0.21 → 1.0.22
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/dist/all/all.d.ts +2 -0
- package/dist/baseclient.js +82 -1
- package/dist/baseclient.js.map +1 -1
- package/dist/emit/all.d.ts +1 -0
- package/dist/emit/emit.d.ts +7 -0
- package/dist/util/bintrie.d.ts +1 -0
- package/lib/all/all.ts +2 -0
- package/lib/emit/all.ts +1 -0
- package/lib/emit/emit.ts +40 -0
- package/lib/util/bintrie.ts +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './emit';
|
package/dist/util/bintrie.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ export declare class BinTrie {
|
|
|
69
69
|
constructor(coder: Coder);
|
|
70
70
|
static fromBuffer(coder: Coder, ab: ArrayBuffer): BinTrie;
|
|
71
71
|
get(key: string): string;
|
|
72
|
+
forEach(cb: (k: string, v: string) => void): void;
|
|
72
73
|
}
|
|
73
74
|
export interface BinTrieOptions {
|
|
74
75
|
dedup?: boolean;
|
package/lib/all/all.ts
CHANGED
package/lib/emit/all.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './emit';
|
package/lib/emit/emit.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class Emit
|
|
2
|
+
{
|
|
3
|
+
onList: any;
|
|
4
|
+
|
|
5
|
+
constructor()
|
|
6
|
+
{
|
|
7
|
+
this.onList = {};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
on(eventName: string, cb: any): void
|
|
11
|
+
{
|
|
12
|
+
let aCB: any = this.onList[eventName];
|
|
13
|
+
if (aCB === undefined)
|
|
14
|
+
{
|
|
15
|
+
aCB = [];
|
|
16
|
+
this.onList[eventName] = aCB;
|
|
17
|
+
}
|
|
18
|
+
aCB.push(cb);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
emit(eventName: string, arg1?: any, arg2?: any, arg3?: any): void
|
|
22
|
+
{
|
|
23
|
+
let aCB: any[] = this.onList[eventName];
|
|
24
|
+
if (aCB !== undefined)
|
|
25
|
+
for (let i: number = 0; i < aCB.length; i++)
|
|
26
|
+
(aCB[i])(arg1, arg2, arg3);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
off(eventName: string, cb: any): void
|
|
30
|
+
{
|
|
31
|
+
let aCB: any = this.onList[eventName];
|
|
32
|
+
if (aCB !== undefined)
|
|
33
|
+
for (let i: number = 0; i < aCB.length; i++)
|
|
34
|
+
if (aCB[i] === cb)
|
|
35
|
+
{
|
|
36
|
+
aCB.splice(i, 1);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/lib/util/bintrie.ts
CHANGED
|
@@ -57,6 +57,8 @@ Util.setCoder({ encoder: new u.TextEncoder(), decoder: new u.TextDecoder('utf-8'
|
|
|
57
57
|
Util.setCoder({ encoder: new TextEncoder(), decoder: new TextDecoder('utf-8') });
|
|
58
58
|
*/
|
|
59
59
|
|
|
60
|
+
const MaxKeyLength = 128;
|
|
61
|
+
|
|
60
62
|
export function s2u8(coder: Coder, s: string): Uint8Array
|
|
61
63
|
{
|
|
62
64
|
return coder.encoder.encode(s);
|
|
@@ -343,6 +345,23 @@ export class BinTrie
|
|
|
343
345
|
}
|
|
344
346
|
return undefined;
|
|
345
347
|
}
|
|
348
|
+
|
|
349
|
+
forEach(cb: (k: string, v: string) => void)
|
|
350
|
+
{
|
|
351
|
+
let keybuf = new Uint8Array(MaxKeyLength);
|
|
352
|
+
let keylen = 0;
|
|
353
|
+
|
|
354
|
+
let processNode = (len: number, byteOffset: number) => {
|
|
355
|
+
let iOffset = byteOffset >> 2;
|
|
356
|
+
let n = this.i32[iOffset];
|
|
357
|
+
byteOffset += 4;
|
|
358
|
+
for (let j = 0; j < n; j++)
|
|
359
|
+
{
|
|
360
|
+
keybuf[keylen++] = this.u8[byteOffset+j];
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
processNode(0, 4);
|
|
364
|
+
}
|
|
346
365
|
}
|
|
347
366
|
|
|
348
367
|
export interface BinTrieOptions
|