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
@@ -3,6 +3,61 @@
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
5
 
6
+ // src/common/error.ts
7
+ function raise(ErrorClass, message) {
8
+ throw new ErrorClass(message);
9
+ }
10
+ __name(raise, "raise");
11
+ var ERR = {
12
+ // Range / index
13
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
14
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
15
+ // Type / argument
16
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
17
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
18
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
19
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
20
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
21
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
22
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
23
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
24
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
25
+ // State / operation
26
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
27
+ // Matrix
28
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
29
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
30
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
31
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
32
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
33
+ // Order statistic
34
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
35
+ };
36
+
37
+ // src/common/index.ts
38
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
39
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
40
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
41
+ return DFSOperation2;
42
+ })(DFSOperation || {});
43
+ var Range = class {
44
+ constructor(low, high, includeLow = true, includeHigh = true) {
45
+ this.low = low;
46
+ this.high = high;
47
+ this.includeLow = includeLow;
48
+ this.includeHigh = includeHigh;
49
+ }
50
+ static {
51
+ __name(this, "Range");
52
+ }
53
+ // Determine whether a key is within the range
54
+ isInRange(key, comparator) {
55
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
56
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
57
+ return lowCheck && highCheck;
58
+ }
59
+ };
60
+
6
61
  // src/data-structures/base/iterable-element-base.ts
7
62
  var IterableElementBase = class {
8
63
  static {
@@ -21,7 +76,7 @@ var IterableElementBase = class {
21
76
  if (options) {
22
77
  const { toElementFn } = options;
23
78
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
24
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
79
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
25
80
  }
26
81
  }
27
82
  /**
@@ -184,7 +239,7 @@ var IterableElementBase = class {
184
239
  acc = initialValue;
185
240
  } else {
186
241
  const first = iter.next();
187
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
242
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
188
243
  acc = first.value;
189
244
  index = 1;
190
245
  }
@@ -226,55 +281,6 @@ var IterableElementBase = class {
226
281
  }
227
282
  };
228
283
 
229
- // src/common/error.ts
230
- var ERR = {
231
- // Range / index
232
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
233
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
234
- // Type / argument
235
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
236
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
237
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
238
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
239
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
240
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
241
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
242
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
243
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
244
- // State / operation
245
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
246
- // Matrix
247
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
248
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
249
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
250
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
251
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
252
- };
253
-
254
- // src/common/index.ts
255
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
256
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
257
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
258
- return DFSOperation2;
259
- })(DFSOperation || {});
260
- var Range = class {
261
- constructor(low, high, includeLow = true, includeHigh = true) {
262
- this.low = low;
263
- this.high = high;
264
- this.includeLow = includeLow;
265
- this.includeHigh = includeHigh;
266
- }
267
- static {
268
- __name(this, "Range");
269
- }
270
- // Determine whether a key is within the range
271
- isInRange(key, comparator) {
272
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
273
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
274
- return lowCheck && highCheck;
275
- }
276
- };
277
-
278
284
  // src/data-structures/heap/heap.ts
279
285
  var Heap = class _Heap extends IterableElementBase {
280
286
  static {
@@ -320,6 +326,30 @@ var Heap = class _Heap extends IterableElementBase {
320
326
 
321
327
 
322
328
 
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
323
353
  * @example
324
354
  * // Track heap capacity
325
355
  * const heap = new Heap<number>();
@@ -382,6 +412,30 @@ var Heap = class _Heap extends IterableElementBase {
382
412
 
383
413
 
384
414
 
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
385
439
  * @example
386
440
  * // basic Heap creation and add operation
387
441
  * // Create a min heap (default)
@@ -415,6 +469,30 @@ var Heap = class _Heap extends IterableElementBase {
415
469
 
416
470
 
417
471
 
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
418
496
  * @example
419
497
  * // Add multiple elements
420
498
  * const heap = new Heap<number>([], { comparator: (a, b) => a - b });
@@ -450,6 +528,30 @@ var Heap = class _Heap extends IterableElementBase {
450
528
 
451
529
 
452
530
 
531
+
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
453
555
  * @example
454
556
  * // Heap with custom comparator (MaxHeap behavior)
455
557
  * interface Task {
@@ -501,6 +603,30 @@ var Heap = class _Heap extends IterableElementBase {
501
603
 
502
604
 
503
605
 
606
+
607
+
608
+
609
+
610
+
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
504
630
  * @example
505
631
  * // Heap for event processing with priority
506
632
  * interface Event {
@@ -577,6 +703,30 @@ var Heap = class _Heap extends IterableElementBase {
577
703
 
578
704
 
579
705
 
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
580
730
  * @example
581
731
  * // Check if heap is empty
582
732
  * const heap = new Heap<number>([], { comparator: (a, b) => a - b });
@@ -600,6 +750,30 @@ var Heap = class _Heap extends IterableElementBase {
600
750
 
601
751
 
602
752
 
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
603
777
  * @example
604
778
  * // Remove all elements
605
779
  * const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
@@ -626,6 +800,30 @@ var Heap = class _Heap extends IterableElementBase {
626
800
  * @returns True if found.
627
801
 
628
802
 
803
+
804
+
805
+
806
+
807
+
808
+
809
+
810
+
811
+
812
+
813
+
814
+
815
+
816
+
817
+
818
+
819
+
820
+
821
+
822
+
823
+
824
+
825
+
826
+
629
827
  * @example
630
828
  * // Check element existence
631
829
  * const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
@@ -649,6 +847,30 @@ var Heap = class _Heap extends IterableElementBase {
649
847
 
650
848
 
651
849
 
850
+
851
+
852
+
853
+
854
+
855
+
856
+
857
+
858
+
859
+
860
+
861
+
862
+
863
+
864
+
865
+
866
+
867
+
868
+
869
+
870
+
871
+
872
+
873
+
652
874
  * @example
653
875
  * // Remove specific element
654
876
  * const heap = new Heap<number>([3, 1, 4, 1, 5], { comparator: (a, b) => a - b });
@@ -718,6 +940,30 @@ var Heap = class _Heap extends IterableElementBase {
718
940
  * @returns Array of visited elements.
719
941
 
720
942
 
943
+
944
+
945
+
946
+
947
+
948
+
949
+
950
+
951
+
952
+
953
+
954
+
955
+
956
+
957
+
958
+
959
+
960
+
961
+
962
+
963
+
964
+
965
+
966
+
721
967
  * @example
722
968
  * // Depth-first traversal
723
969
  * const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
@@ -774,6 +1020,30 @@ var Heap = class _Heap extends IterableElementBase {
774
1020
 
775
1021
 
776
1022
 
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+
1039
+
1040
+
1041
+
1042
+
1043
+
1044
+
1045
+
1046
+
777
1047
  * @example
778
1048
  * // Sort elements using heap
779
1049
  * const heap = new Heap<number>([5, 1, 3, 2, 4]);
@@ -803,6 +1073,30 @@ var Heap = class _Heap extends IterableElementBase {
803
1073
 
804
1074
 
805
1075
 
1076
+
1077
+
1078
+
1079
+
1080
+
1081
+
1082
+
1083
+
1084
+
1085
+
1086
+
1087
+
1088
+
1089
+
1090
+
1091
+
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+
1098
+
1099
+
806
1100
  * @example
807
1101
  * // Create independent copy
808
1102
  * const heap = new Heap<number>([3, 1, 4], { comparator: (a, b) => a - b });
@@ -831,6 +1125,30 @@ var Heap = class _Heap extends IterableElementBase {
831
1125
 
832
1126
 
833
1127
 
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+
1135
+
1136
+
1137
+
1138
+
1139
+
1140
+
1141
+
1142
+
1143
+
1144
+
1145
+
1146
+
1147
+
1148
+
1149
+
1150
+
1151
+
834
1152
  * @example
835
1153
  * // Filter elements
836
1154
  * const heap = new Heap<number>([1, 2, 3, 4, 5], { comparator: (a, b) => a - b });
@@ -866,6 +1184,30 @@ var Heap = class _Heap extends IterableElementBase {
866
1184
 
867
1185
 
868
1186
 
1187
+
1188
+
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+
1195
+
1196
+
1197
+
1198
+
1199
+
1200
+
1201
+
1202
+
1203
+
1204
+
1205
+
1206
+
1207
+
1208
+
1209
+
1210
+
869
1211
  * @example
870
1212
  * // Transform elements
871
1213
  * const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
@@ -874,7 +1216,7 @@ var Heap = class _Heap extends IterableElementBase {
874
1216
  */
875
1217
  map(callback, options, thisArg) {
876
1218
  const { comparator, toElementFn, ...rest } = options ?? {};
877
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1219
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
878
1220
  const out = this._createLike([], { ...rest, comparator, toElementFn });
879
1221
  let i = 0;
880
1222
  for (const x of this) {
@@ -901,7 +1243,7 @@ var Heap = class _Heap extends IterableElementBase {
901
1243
  }
902
1244
  _DEFAULT_COMPARATOR = /* @__PURE__ */ __name((a, b) => {
903
1245
  if (typeof a === "object" || typeof b === "object") {
904
- throw new TypeError(ERR.comparatorRequired("Heap"));
1246
+ raise(TypeError, ERR.comparatorRequired("Heap"));
905
1247
  }
906
1248
  if (a > b) return 1;
907
1249
  if (a < b) return -1;
@@ -1013,7 +1355,7 @@ var FibonacciHeap = class {
1013
1355
  constructor(comparator) {
1014
1356
  this.clear();
1015
1357
  this._comparator = comparator || this._defaultComparator;
1016
- if (typeof this.comparator !== "function") throw new TypeError(ERR.notAFunction("comparator", "FibonacciHeap"));
1358
+ if (typeof this.comparator !== "function") raise(TypeError, ERR.notAFunction("comparator", "FibonacciHeap"));
1017
1359
  }
1018
1360
  _root;
1019
1361
  /**
@@ -1241,7 +1583,7 @@ var MaxPriorityQueue = class extends PriorityQueue {
1241
1583
  super(elements, {
1242
1584
  comparator: /* @__PURE__ */ __name((a, b) => {
1243
1585
  if (typeof a === "object" || typeof b === "object") {
1244
- throw new TypeError(ERR.comparatorRequired("MaxPriorityQueue"));
1586
+ raise(TypeError, ERR.comparatorRequired("MaxPriorityQueue"));
1245
1587
  }
1246
1588
  if (a < b) return 1;
1247
1589
  if (a > b) return -1;
@@ -1274,5 +1616,6 @@ exports.Heap = Heap;
1274
1616
  exports.MaxPriorityQueue = MaxPriorityQueue;
1275
1617
  exports.PriorityQueue = PriorityQueue;
1276
1618
  exports.Range = Range;
1619
+ exports.raise = raise;
1277
1620
  //# sourceMappingURL=index.cjs.map
1278
1621
  //# sourceMappingURL=index.cjs.map