max-priority-queue-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.
Files changed (90) hide show
  1. package/dist/cjs/index.cjs +398 -55
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +397 -54
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +398 -56
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +397 -55
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +9 -0
  10. package/dist/types/common/index.d.ts +1 -1
  11. package/dist/types/data-structures/base/index.d.ts +1 -0
  12. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  13. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  14. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
  15. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
  16. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
  17. package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
  18. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
  19. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
  20. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
  21. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
  22. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
  23. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
  24. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  25. package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
  26. package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
  27. package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
  28. package/dist/types/data-structures/heap/heap.d.ts +336 -0
  29. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
  30. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
  31. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
  32. package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
  33. package/dist/types/data-structures/queue/deque.d.ts +364 -4
  34. package/dist/types/data-structures/queue/queue.d.ts +288 -0
  35. package/dist/types/data-structures/stack/stack.d.ts +240 -0
  36. package/dist/types/data-structures/trie/trie.d.ts +292 -4
  37. package/dist/types/interfaces/graph.d.ts +1 -1
  38. package/dist/types/types/common.d.ts +2 -2
  39. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  40. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  41. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  42. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  43. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  44. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  45. package/dist/types/types/utils/validate-type.d.ts +4 -4
  46. package/dist/umd/max-priority-queue-typed.js +395 -53
  47. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  48. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  49. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/common/error.ts +19 -1
  52. package/src/common/index.ts +1 -1
  53. package/src/data-structures/base/index.ts +1 -0
  54. package/src/data-structures/base/iterable-element-base.ts +3 -2
  55. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  56. package/src/data-structures/base/linear-base.ts +3 -3
  57. package/src/data-structures/binary-tree/avl-tree.ts +299 -0
  58. package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
  59. package/src/data-structures/binary-tree/binary-tree.ts +606 -6
  60. package/src/data-structures/binary-tree/bst.ts +946 -7
  61. package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
  62. package/src/data-structures/binary-tree/segment-tree.ts +145 -2
  63. package/src/data-structures/binary-tree/tree-map.ts +3423 -499
  64. package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
  65. package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
  66. package/src/data-structures/binary-tree/tree-set.ts +3209 -413
  67. package/src/data-structures/graph/abstract-graph.ts +6 -6
  68. package/src/data-structures/graph/directed-graph.ts +240 -0
  69. package/src/data-structures/graph/undirected-graph.ts +216 -0
  70. package/src/data-structures/hash/hash-map.ts +281 -19
  71. package/src/data-structures/heap/heap.ts +340 -4
  72. package/src/data-structures/heap/max-heap.ts +2 -2
  73. package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
  74. package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
  75. package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
  76. package/src/data-structures/matrix/matrix.ts +202 -10
  77. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  78. package/src/data-structures/queue/deque.ts +365 -5
  79. package/src/data-structures/queue/queue.ts +288 -0
  80. package/src/data-structures/stack/stack.ts +240 -0
  81. package/src/data-structures/trie/trie.ts +295 -7
  82. package/src/interfaces/graph.ts +1 -1
  83. package/src/types/common.ts +2 -2
  84. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  85. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  86. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  87. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  88. package/src/types/data-structures/heap/heap.ts +1 -0
  89. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  90. package/src/types/utils/validate-type.ts +4 -4
@@ -1,6 +1,61 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
+ // src/common/error.ts
5
+ function raise(ErrorClass, message) {
6
+ throw new ErrorClass(message);
7
+ }
8
+ __name(raise, "raise");
9
+ var ERR = {
10
+ // Range / index
11
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
12
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
13
+ // Type / argument
14
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
15
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
16
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
17
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
18
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
19
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
20
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
21
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
22
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
23
+ // State / operation
24
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
25
+ // Matrix
26
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
27
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
28
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
29
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
30
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
31
+ // Order statistic
32
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
33
+ };
34
+
35
+ // src/common/index.ts
36
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
37
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
38
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
39
+ return DFSOperation2;
40
+ })(DFSOperation || {});
41
+ var Range = class {
42
+ constructor(low, high, includeLow = true, includeHigh = true) {
43
+ this.low = low;
44
+ this.high = high;
45
+ this.includeLow = includeLow;
46
+ this.includeHigh = includeHigh;
47
+ }
48
+ static {
49
+ __name(this, "Range");
50
+ }
51
+ // Determine whether a key is within the range
52
+ isInRange(key, comparator) {
53
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
54
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
55
+ return lowCheck && highCheck;
56
+ }
57
+ };
58
+
4
59
  // src/data-structures/base/iterable-element-base.ts
5
60
  var IterableElementBase = class {
6
61
  static {
@@ -19,7 +74,7 @@ var IterableElementBase = class {
19
74
  if (options) {
20
75
  const { toElementFn } = options;
21
76
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
22
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
77
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
23
78
  }
24
79
  }
25
80
  /**
@@ -182,7 +237,7 @@ var IterableElementBase = class {
182
237
  acc = initialValue;
183
238
  } else {
184
239
  const first = iter.next();
185
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
240
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
186
241
  acc = first.value;
187
242
  index = 1;
188
243
  }
@@ -224,55 +279,6 @@ var IterableElementBase = class {
224
279
  }
225
280
  };
226
281
 
227
- // src/common/error.ts
228
- var ERR = {
229
- // Range / index
230
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
231
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
232
- // Type / argument
233
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
234
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
235
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
236
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
237
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
238
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
239
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
240
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
241
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
242
- // State / operation
243
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
244
- // Matrix
245
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
246
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
247
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
248
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
249
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
250
- };
251
-
252
- // src/common/index.ts
253
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
254
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
255
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
256
- return DFSOperation2;
257
- })(DFSOperation || {});
258
- var Range = class {
259
- constructor(low, high, includeLow = true, includeHigh = true) {
260
- this.low = low;
261
- this.high = high;
262
- this.includeLow = includeLow;
263
- this.includeHigh = includeHigh;
264
- }
265
- static {
266
- __name(this, "Range");
267
- }
268
- // Determine whether a key is within the range
269
- isInRange(key, comparator) {
270
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
271
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
272
- return lowCheck && highCheck;
273
- }
274
- };
275
-
276
282
  // src/data-structures/heap/heap.ts
277
283
  var Heap = class _Heap extends IterableElementBase {
278
284
  static {
@@ -318,6 +324,30 @@ var Heap = class _Heap extends IterableElementBase {
318
324
 
319
325
 
320
326
 
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
321
351
  * @example
322
352
  * // Track heap capacity
323
353
  * const heap = new Heap<number>();
@@ -380,6 +410,30 @@ var Heap = class _Heap extends IterableElementBase {
380
410
 
381
411
 
382
412
 
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
383
437
  * @example
384
438
  * // basic Heap creation and add operation
385
439
  * // Create a min heap (default)
@@ -413,6 +467,30 @@ var Heap = class _Heap extends IterableElementBase {
413
467
 
414
468
 
415
469
 
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
416
494
  * @example
417
495
  * // Add multiple elements
418
496
  * const heap = new Heap<number>([], { comparator: (a, b) => a - b });
@@ -448,6 +526,30 @@ var Heap = class _Heap extends IterableElementBase {
448
526
 
449
527
 
450
528
 
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
451
553
  * @example
452
554
  * // Heap with custom comparator (MaxHeap behavior)
453
555
  * interface Task {
@@ -499,6 +601,30 @@ var Heap = class _Heap extends IterableElementBase {
499
601
 
500
602
 
501
603
 
604
+
605
+
606
+
607
+
608
+
609
+
610
+
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
502
628
  * @example
503
629
  * // Heap for event processing with priority
504
630
  * interface Event {
@@ -575,6 +701,30 @@ var Heap = class _Heap extends IterableElementBase {
575
701
 
576
702
 
577
703
 
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+
578
728
  * @example
579
729
  * // Check if heap is empty
580
730
  * const heap = new Heap<number>([], { comparator: (a, b) => a - b });
@@ -598,6 +748,30 @@ var Heap = class _Heap extends IterableElementBase {
598
748
 
599
749
 
600
750
 
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
601
775
  * @example
602
776
  * // Remove all elements
603
777
  * const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
@@ -624,6 +798,30 @@ var Heap = class _Heap extends IterableElementBase {
624
798
  * @returns True if found.
625
799
 
626
800
 
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+
809
+
810
+
811
+
812
+
813
+
814
+
815
+
816
+
817
+
818
+
819
+
820
+
821
+
822
+
823
+
824
+
627
825
  * @example
628
826
  * // Check element existence
629
827
  * const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
@@ -647,6 +845,30 @@ var Heap = class _Heap extends IterableElementBase {
647
845
 
648
846
 
649
847
 
848
+
849
+
850
+
851
+
852
+
853
+
854
+
855
+
856
+
857
+
858
+
859
+
860
+
861
+
862
+
863
+
864
+
865
+
866
+
867
+
868
+
869
+
870
+
871
+
650
872
  * @example
651
873
  * // Remove specific element
652
874
  * const heap = new Heap<number>([3, 1, 4, 1, 5], { comparator: (a, b) => a - b });
@@ -716,6 +938,30 @@ var Heap = class _Heap extends IterableElementBase {
716
938
  * @returns Array of visited elements.
717
939
 
718
940
 
941
+
942
+
943
+
944
+
945
+
946
+
947
+
948
+
949
+
950
+
951
+
952
+
953
+
954
+
955
+
956
+
957
+
958
+
959
+
960
+
961
+
962
+
963
+
964
+
719
965
  * @example
720
966
  * // Depth-first traversal
721
967
  * const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
@@ -772,6 +1018,30 @@ var Heap = class _Heap extends IterableElementBase {
772
1018
 
773
1019
 
774
1020
 
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+
1039
+
1040
+
1041
+
1042
+
1043
+
1044
+
775
1045
  * @example
776
1046
  * // Sort elements using heap
777
1047
  * const heap = new Heap<number>([5, 1, 3, 2, 4]);
@@ -801,6 +1071,30 @@ var Heap = class _Heap extends IterableElementBase {
801
1071
 
802
1072
 
803
1073
 
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+
1080
+
1081
+
1082
+
1083
+
1084
+
1085
+
1086
+
1087
+
1088
+
1089
+
1090
+
1091
+
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+
804
1098
  * @example
805
1099
  * // Create independent copy
806
1100
  * const heap = new Heap<number>([3, 1, 4], { comparator: (a, b) => a - b });
@@ -829,6 +1123,30 @@ var Heap = class _Heap extends IterableElementBase {
829
1123
 
830
1124
 
831
1125
 
1126
+
1127
+
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+
1135
+
1136
+
1137
+
1138
+
1139
+
1140
+
1141
+
1142
+
1143
+
1144
+
1145
+
1146
+
1147
+
1148
+
1149
+
832
1150
  * @example
833
1151
  * // Filter elements
834
1152
  * const heap = new Heap<number>([1, 2, 3, 4, 5], { comparator: (a, b) => a - b });
@@ -864,6 +1182,30 @@ var Heap = class _Heap extends IterableElementBase {
864
1182
 
865
1183
 
866
1184
 
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+
1195
+
1196
+
1197
+
1198
+
1199
+
1200
+
1201
+
1202
+
1203
+
1204
+
1205
+
1206
+
1207
+
1208
+
867
1209
  * @example
868
1210
  * // Transform elements
869
1211
  * const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
@@ -872,7 +1214,7 @@ var Heap = class _Heap extends IterableElementBase {
872
1214
  */
873
1215
  map(callback, options, thisArg) {
874
1216
  const { comparator, toElementFn, ...rest } = options ?? {};
875
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1217
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
876
1218
  const out = this._createLike([], { ...rest, comparator, toElementFn });
877
1219
  let i = 0;
878
1220
  for (const x of this) {
@@ -899,7 +1241,7 @@ var Heap = class _Heap extends IterableElementBase {
899
1241
  }
900
1242
  _DEFAULT_COMPARATOR = /* @__PURE__ */ __name((a, b) => {
901
1243
  if (typeof a === "object" || typeof b === "object") {
902
- throw new TypeError(ERR.comparatorRequired("Heap"));
1244
+ raise(TypeError, ERR.comparatorRequired("Heap"));
903
1245
  }
904
1246
  if (a > b) return 1;
905
1247
  if (a < b) return -1;
@@ -1011,7 +1353,7 @@ var FibonacciHeap = class {
1011
1353
  constructor(comparator) {
1012
1354
  this.clear();
1013
1355
  this._comparator = comparator || this._defaultComparator;
1014
- if (typeof this.comparator !== "function") throw new TypeError(ERR.notAFunction("comparator", "FibonacciHeap"));
1356
+ if (typeof this.comparator !== "function") raise(TypeError, ERR.notAFunction("comparator", "FibonacciHeap"));
1015
1357
  }
1016
1358
  _root;
1017
1359
  /**
@@ -1239,7 +1581,7 @@ var MaxPriorityQueue = class extends PriorityQueue {
1239
1581
  super(elements, {
1240
1582
  comparator: /* @__PURE__ */ __name((a, b) => {
1241
1583
  if (typeof a === "object" || typeof b === "object") {
1242
- throw new TypeError(ERR.comparatorRequired("MaxPriorityQueue"));
1584
+ raise(TypeError, ERR.comparatorRequired("MaxPriorityQueue"));
1243
1585
  }
1244
1586
  if (a < b) return 1;
1245
1587
  if (a > b) return -1;
@@ -1264,6 +1606,6 @@ var MaxPriorityQueue = class extends PriorityQueue {
1264
1606
  * @license MIT License
1265
1607
  */
1266
1608
 
1267
- export { DFSOperation, ERR, FibonacciHeap, FibonacciHeapNode, Heap, MaxPriorityQueue, PriorityQueue, Range };
1609
+ export { DFSOperation, ERR, FibonacciHeap, FibonacciHeapNode, Heap, MaxPriorityQueue, PriorityQueue, Range, raise };
1268
1610
  //# sourceMappingURL=index.mjs.map
1269
1611
  //# sourceMappingURL=index.mjs.map