@dra2020/baseclient 1.0.19 → 1.0.20
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/baseclient.js +28 -15
- package/dist/baseclient.js.map +1 -1
- package/dist/util/bintrie.d.ts +6 -2
- package/lib/util/bintrie.ts +15 -4
- package/package.json +1 -1
package/dist/util/bintrie.d.ts
CHANGED
|
@@ -70,7 +70,11 @@ export declare class BinTrie {
|
|
|
70
70
|
static fromBuffer(coder: Coder, ab: ArrayBuffer): BinTrie;
|
|
71
71
|
get(key: string): string;
|
|
72
72
|
}
|
|
73
|
+
export interface BinTrieOptions {
|
|
74
|
+
dedup?: boolean;
|
|
75
|
+
}
|
|
73
76
|
export declare class BinTrieBuilder {
|
|
77
|
+
options: BinTrieOptions;
|
|
74
78
|
coder: Coder;
|
|
75
79
|
root: UnpackedNode;
|
|
76
80
|
vtb: ValueTableBuilder;
|
|
@@ -78,7 +82,7 @@ export declare class BinTrieBuilder {
|
|
|
78
82
|
ab: ArrayBuffer;
|
|
79
83
|
u8: Uint8Array;
|
|
80
84
|
i32: Int32Array;
|
|
81
|
-
constructor(coder: Coder);
|
|
85
|
+
constructor(coder: Coder, options?: BinTrieOptions);
|
|
82
86
|
nodeCount(node: UnpackedNode): number;
|
|
83
87
|
nodeBranching(node: UnpackedNode, counts: number[]): number;
|
|
84
88
|
nodeValueCount(node: UnpackedNode): number;
|
|
@@ -88,6 +92,6 @@ export declare class BinTrieBuilder {
|
|
|
88
92
|
getUnpacked(key: string): string;
|
|
89
93
|
packNode(node: UnpackedNode, byteOffset: number): number;
|
|
90
94
|
toBinary(): void;
|
|
91
|
-
static fromMap(coder: Coder, o: StringMap): BinTrie;
|
|
95
|
+
static fromMap(coder: Coder, o: StringMap, options?: BinTrieOptions): BinTrie;
|
|
92
96
|
}
|
|
93
97
|
export {};
|
package/lib/util/bintrie.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as U from './util';
|
|
2
|
+
|
|
1
3
|
//
|
|
2
4
|
// Packed format Trie for mapping string to string
|
|
3
5
|
// Assumptions:
|
|
@@ -343,8 +345,15 @@ export class BinTrie
|
|
|
343
345
|
}
|
|
344
346
|
}
|
|
345
347
|
|
|
348
|
+
export interface BinTrieOptions
|
|
349
|
+
{
|
|
350
|
+
dedup?: boolean,
|
|
351
|
+
}
|
|
352
|
+
let DefaultOptions: BinTrieOptions = { dedup: true };
|
|
353
|
+
|
|
346
354
|
export class BinTrieBuilder
|
|
347
355
|
{
|
|
356
|
+
options: BinTrieOptions;
|
|
348
357
|
coder: Coder;
|
|
349
358
|
root: UnpackedNode;
|
|
350
359
|
vtb: ValueTableBuilder;
|
|
@@ -353,9 +362,10 @@ export class BinTrieBuilder
|
|
|
353
362
|
u8: Uint8Array;
|
|
354
363
|
i32: Int32Array;
|
|
355
364
|
|
|
356
|
-
constructor(coder: Coder)
|
|
365
|
+
constructor(coder: Coder, options?: BinTrieOptions)
|
|
357
366
|
{
|
|
358
367
|
this.coder = coder;
|
|
368
|
+
this.options = U.shallowAssignImmutable(DefaultOptions, options);
|
|
359
369
|
}
|
|
360
370
|
|
|
361
371
|
// Building
|
|
@@ -542,9 +552,9 @@ export class BinTrieBuilder
|
|
|
542
552
|
}
|
|
543
553
|
|
|
544
554
|
// Building
|
|
545
|
-
static fromMap(coder: Coder, o: StringMap): BinTrie
|
|
555
|
+
static fromMap(coder: Coder, o: StringMap, options?: BinTrieOptions): BinTrie
|
|
546
556
|
{
|
|
547
|
-
let btb = new BinTrieBuilder(coder);
|
|
557
|
+
let btb = new BinTrieBuilder(coder, options);
|
|
548
558
|
btb.vtb = ValueTableBuilder.fromStrings(coder, Object.values(o));
|
|
549
559
|
btb.vt = ValueTable.fromBuffer(coder, btb.vtb.ab, 0, btb.vtb.ab.byteLength);
|
|
550
560
|
let keys = Object.keys(o);
|
|
@@ -563,7 +573,8 @@ export class BinTrieBuilder
|
|
|
563
573
|
});
|
|
564
574
|
|
|
565
575
|
// dedup (collapse branches pointing to same value)
|
|
566
|
-
btb.dedup
|
|
576
|
+
if (btb.options.dedup)
|
|
577
|
+
btb.dedup(btb.root);
|
|
567
578
|
|
|
568
579
|
// validate
|
|
569
580
|
keys.forEach(k => {
|