trie-typed 2.5.0 → 2.5.2
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/cjs/index.cjs +323 -52
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +322 -51
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +323 -53
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +322 -52
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
- package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
- package/dist/types/data-structures/heap/heap.d.ts +336 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
- package/dist/types/data-structures/queue/deque.d.ts +364 -4
- package/dist/types/data-structures/queue/queue.d.ts +288 -0
- package/dist/types/data-structures/stack/stack.d.ts +240 -0
- package/dist/types/data-structures/trie/trie.d.ts +292 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/trie-typed.js +320 -50
- package/dist/umd/trie-typed.js.map +1 -1
- package/dist/umd/trie-typed.min.js +1 -1
- package/dist/umd/trie-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +299 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
- package/src/data-structures/binary-tree/binary-tree.ts +606 -6
- package/src/data-structures/binary-tree/bst.ts +946 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
- package/src/data-structures/binary-tree/segment-tree.ts +145 -2
- package/src/data-structures/binary-tree/tree-map.ts +3423 -499
- package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
- package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
- package/src/data-structures/binary-tree/tree-set.ts +3209 -413
- package/src/data-structures/graph/abstract-graph.ts +6 -6
- package/src/data-structures/graph/directed-graph.ts +240 -0
- package/src/data-structures/graph/undirected-graph.ts +216 -0
- package/src/data-structures/hash/hash-map.ts +281 -19
- package/src/data-structures/heap/heap.ts +340 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
- package/src/data-structures/matrix/matrix.ts +202 -10
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +365 -5
- package/src/data-structures/queue/queue.ts +288 -0
- package/src/data-structures/stack/stack.ts +240 -0
- package/src/data-structures/trie/trie.ts +295 -7
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
package/dist/umd/trie-typed.js
CHANGED
|
@@ -27,9 +27,61 @@ var trieTyped = (() => {
|
|
|
27
27
|
ERR: () => ERR,
|
|
28
28
|
Range: () => Range,
|
|
29
29
|
Trie: () => Trie,
|
|
30
|
-
TrieNode: () => TrieNode
|
|
30
|
+
TrieNode: () => TrieNode,
|
|
31
|
+
raise: () => raise
|
|
31
32
|
});
|
|
32
33
|
|
|
34
|
+
// src/common/error.ts
|
|
35
|
+
function raise(ErrorClass, message) {
|
|
36
|
+
throw new ErrorClass(message);
|
|
37
|
+
}
|
|
38
|
+
var ERR = {
|
|
39
|
+
// Range / index
|
|
40
|
+
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
41
|
+
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
42
|
+
// Type / argument
|
|
43
|
+
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
44
|
+
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
45
|
+
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
46
|
+
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
47
|
+
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
48
|
+
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
49
|
+
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
50
|
+
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
51
|
+
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
52
|
+
// State / operation
|
|
53
|
+
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
54
|
+
// Matrix
|
|
55
|
+
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
56
|
+
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
57
|
+
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
58
|
+
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
59
|
+
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
|
|
60
|
+
// Order statistic
|
|
61
|
+
orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/common/index.ts
|
|
65
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
66
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
67
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
68
|
+
return DFSOperation2;
|
|
69
|
+
})(DFSOperation || {});
|
|
70
|
+
var Range = class {
|
|
71
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
72
|
+
this.low = low;
|
|
73
|
+
this.high = high;
|
|
74
|
+
this.includeLow = includeLow;
|
|
75
|
+
this.includeHigh = includeHigh;
|
|
76
|
+
}
|
|
77
|
+
// Determine whether a key is within the range
|
|
78
|
+
isInRange(key, comparator) {
|
|
79
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
80
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
81
|
+
return lowCheck && highCheck;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
33
85
|
// src/data-structures/base/iterable-element-base.ts
|
|
34
86
|
var IterableElementBase = class {
|
|
35
87
|
/**
|
|
@@ -52,7 +104,7 @@ var trieTyped = (() => {
|
|
|
52
104
|
if (options) {
|
|
53
105
|
const { toElementFn } = options;
|
|
54
106
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
55
|
-
else if (toElementFn)
|
|
107
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
56
108
|
}
|
|
57
109
|
}
|
|
58
110
|
/**
|
|
@@ -208,7 +260,7 @@ var trieTyped = (() => {
|
|
|
208
260
|
acc = initialValue;
|
|
209
261
|
} else {
|
|
210
262
|
const first = iter.next();
|
|
211
|
-
if (first.done)
|
|
263
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
212
264
|
acc = first.value;
|
|
213
265
|
index = 1;
|
|
214
266
|
}
|
|
@@ -250,52 +302,6 @@ var trieTyped = (() => {
|
|
|
250
302
|
}
|
|
251
303
|
};
|
|
252
304
|
|
|
253
|
-
// src/common/error.ts
|
|
254
|
-
var ERR = {
|
|
255
|
-
// Range / index
|
|
256
|
-
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
257
|
-
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
258
|
-
// Type / argument
|
|
259
|
-
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
260
|
-
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
261
|
-
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
262
|
-
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
263
|
-
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
264
|
-
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
265
|
-
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
266
|
-
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
267
|
-
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
268
|
-
// State / operation
|
|
269
|
-
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
270
|
-
// Matrix
|
|
271
|
-
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
272
|
-
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
273
|
-
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
274
|
-
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
275
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
// src/common/index.ts
|
|
279
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
280
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
281
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
282
|
-
return DFSOperation2;
|
|
283
|
-
})(DFSOperation || {});
|
|
284
|
-
var Range = class {
|
|
285
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
286
|
-
this.low = low;
|
|
287
|
-
this.high = high;
|
|
288
|
-
this.includeLow = includeLow;
|
|
289
|
-
this.includeHigh = includeHigh;
|
|
290
|
-
}
|
|
291
|
-
// Determine whether a key is within the range
|
|
292
|
-
isInRange(key, comparator) {
|
|
293
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
294
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
295
|
-
return lowCheck && highCheck;
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
|
|
299
305
|
// src/data-structures/trie/trie.ts
|
|
300
306
|
var TrieNode = class {
|
|
301
307
|
/**
|
|
@@ -432,6 +438,30 @@ var trieTyped = (() => {
|
|
|
432
438
|
|
|
433
439
|
|
|
434
440
|
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
435
465
|
* @example
|
|
436
466
|
* // basic Trie creation and add words
|
|
437
467
|
* // Create a simple Trie with initial words
|
|
@@ -480,6 +510,30 @@ var trieTyped = (() => {
|
|
|
480
510
|
|
|
481
511
|
|
|
482
512
|
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
483
537
|
* @example
|
|
484
538
|
* // Add multiple words
|
|
485
539
|
* const trie = new Trie();
|
|
@@ -515,6 +569,30 @@ var trieTyped = (() => {
|
|
|
515
569
|
|
|
516
570
|
|
|
517
571
|
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
518
596
|
* @example
|
|
519
597
|
* // Check if a word exists
|
|
520
598
|
* const dict = new Trie(['apple', 'app', 'application']);
|
|
@@ -545,6 +623,30 @@ var trieTyped = (() => {
|
|
|
545
623
|
|
|
546
624
|
|
|
547
625
|
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
548
650
|
* @example
|
|
549
651
|
* // Check if empty
|
|
550
652
|
* const trie = new Trie();
|
|
@@ -567,6 +669,30 @@ var trieTyped = (() => {
|
|
|
567
669
|
|
|
568
670
|
|
|
569
671
|
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
570
696
|
* @example
|
|
571
697
|
* // Remove all words
|
|
572
698
|
* const trie = new Trie(['a', 'b', 'c']);
|
|
@@ -593,6 +719,30 @@ var trieTyped = (() => {
|
|
|
593
719
|
|
|
594
720
|
|
|
595
721
|
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
596
746
|
* @example
|
|
597
747
|
* // Trie delete and iteration
|
|
598
748
|
* const trie = new Trie(['car', 'card', 'care', 'careful', 'can', 'cat']);
|
|
@@ -701,6 +851,30 @@ var trieTyped = (() => {
|
|
|
701
851
|
|
|
702
852
|
|
|
703
853
|
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
704
878
|
* @example
|
|
705
879
|
* // Check if a prefix exists
|
|
706
880
|
* const trie = new Trie(['hello', 'help', 'world']);
|
|
@@ -753,6 +927,30 @@ var trieTyped = (() => {
|
|
|
753
927
|
|
|
754
928
|
|
|
755
929
|
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
756
954
|
* @example
|
|
757
955
|
* // Find shared prefix
|
|
758
956
|
* const trie = new Trie(['flower', 'flow', 'flight']);
|
|
@@ -788,6 +986,30 @@ var trieTyped = (() => {
|
|
|
788
986
|
|
|
789
987
|
|
|
790
988
|
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
791
1013
|
* @example
|
|
792
1014
|
* // Trie getWords and prefix search
|
|
793
1015
|
* const trie = new Trie(['apple', 'app', 'apply', 'application', 'apricot']);
|
|
@@ -841,6 +1063,30 @@ var trieTyped = (() => {
|
|
|
841
1063
|
|
|
842
1064
|
|
|
843
1065
|
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
|
|
844
1090
|
* @example
|
|
845
1091
|
* // Create independent copy
|
|
846
1092
|
* const trie = new Trie(['hello', 'world']);
|
|
@@ -867,6 +1113,30 @@ var trieTyped = (() => {
|
|
|
867
1113
|
|
|
868
1114
|
|
|
869
1115
|
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
870
1140
|
* @example
|
|
871
1141
|
* // Filter words
|
|
872
1142
|
* const trie = new Trie(['cat', 'car', 'dog', 'card']);
|
|
@@ -890,7 +1160,7 @@ var trieTyped = (() => {
|
|
|
890
1160
|
for (const x of this) {
|
|
891
1161
|
const v = thisArg === void 0 ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);
|
|
892
1162
|
if (typeof v !== "string") {
|
|
893
|
-
|
|
1163
|
+
raise(TypeError, ERR.callbackReturnType("string", typeof v, "Trie.map"));
|
|
894
1164
|
}
|
|
895
1165
|
newTrie.add(v);
|
|
896
1166
|
}
|