priority-queue-typed 2.5.1 → 2.5.3

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 (75) hide show
  1. package/dist/cjs/index.cjs +208 -72
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +207 -71
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +208 -73
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +207 -72
  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/binary-tree/avl-tree.d.ts +86 -2
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  24. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +127 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  32. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  33. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  34. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  35. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  36. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  37. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  38. package/dist/umd/priority-queue-typed.js +205 -70
  39. package/dist/umd/priority-queue-typed.js.map +1 -1
  40. package/dist/umd/priority-queue-typed.min.js +1 -1
  41. package/dist/umd/priority-queue-typed.min.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/common/error.ts +19 -1
  44. package/src/common/index.ts +1 -1
  45. package/src/data-structures/base/iterable-element-base.ts +3 -2
  46. package/src/data-structures/binary-tree/avl-tree.ts +99 -5
  47. package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
  48. package/src/data-structures/binary-tree/binary-tree.ts +239 -78
  49. package/src/data-structures/binary-tree/bst.ts +542 -13
  50. package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
  51. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  52. package/src/data-structures/binary-tree/tree-map.ts +1223 -261
  53. package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
  54. package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
  55. package/src/data-structures/binary-tree/tree-set.ts +1018 -99
  56. package/src/data-structures/graph/abstract-graph.ts +2 -2
  57. package/src/data-structures/graph/directed-graph.ts +71 -1
  58. package/src/data-structures/graph/undirected-graph.ts +64 -1
  59. package/src/data-structures/hash/hash-map.ts +102 -16
  60. package/src/data-structures/heap/heap.ts +153 -23
  61. package/src/data-structures/heap/max-heap.ts +2 -2
  62. package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
  63. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  64. package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
  65. package/src/data-structures/matrix/matrix.ts +65 -9
  66. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  67. package/src/data-structures/queue/deque.ts +130 -0
  68. package/src/data-structures/queue/queue.ts +109 -0
  69. package/src/data-structures/stack/stack.ts +75 -5
  70. package/src/data-structures/trie/trie.ts +86 -2
  71. package/src/interfaces/binary-tree.ts +1 -9
  72. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  73. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  74. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  75. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -33,9 +33,61 @@ var priorityQueueTyped = (() => {
33
33
  MinHeap: () => MinHeap,
34
34
  MinPriorityQueue: () => MinPriorityQueue,
35
35
  PriorityQueue: () => PriorityQueue,
36
- Range: () => Range
36
+ Range: () => Range,
37
+ raise: () => raise
37
38
  });
38
39
 
40
+ // src/common/error.ts
41
+ function raise(ErrorClass, message) {
42
+ throw new ErrorClass(message);
43
+ }
44
+ var ERR = {
45
+ // Range / index
46
+ indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
47
+ invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
48
+ // Type / argument
49
+ invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
50
+ comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
51
+ invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
52
+ notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
53
+ invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
54
+ invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
55
+ invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
56
+ reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
57
+ callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
58
+ // State / operation
59
+ invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
60
+ // Matrix
61
+ matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
62
+ matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
63
+ matrixNotSquare: () => "Matrix: Must be square for inversion.",
64
+ matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
65
+ matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
66
+ // Order statistic
67
+ orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
68
+ };
69
+
70
+ // src/common/index.ts
71
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
72
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
73
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
74
+ return DFSOperation2;
75
+ })(DFSOperation || {});
76
+ var Range = class {
77
+ constructor(low, high, includeLow = true, includeHigh = true) {
78
+ this.low = low;
79
+ this.high = high;
80
+ this.includeLow = includeLow;
81
+ this.includeHigh = includeHigh;
82
+ }
83
+ // Determine whether a key is within the range
84
+ isInRange(key, comparator) {
85
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
86
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
87
+ return lowCheck && highCheck;
88
+ }
89
+ };
90
+
39
91
  // src/data-structures/base/iterable-element-base.ts
40
92
  var IterableElementBase = class {
41
93
  /**
@@ -58,7 +110,7 @@ var priorityQueueTyped = (() => {
58
110
  if (options) {
59
111
  const { toElementFn } = options;
60
112
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
61
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
113
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
62
114
  }
63
115
  }
64
116
  /**
@@ -214,7 +266,7 @@ var priorityQueueTyped = (() => {
214
266
  acc = initialValue;
215
267
  } else {
216
268
  const first = iter.next();
217
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
269
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
218
270
  acc = first.value;
219
271
  index = 1;
220
272
  }
@@ -256,52 +308,6 @@ var priorityQueueTyped = (() => {
256
308
  }
257
309
  };
258
310
 
259
- // src/common/error.ts
260
- var ERR = {
261
- // Range / index
262
- indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
263
- invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
264
- // Type / argument
265
- invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
266
- comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
267
- invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
268
- notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
269
- invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
270
- invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
271
- invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
272
- reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
273
- callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
274
- // State / operation
275
- invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
276
- // Matrix
277
- matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
278
- matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
279
- matrixNotSquare: () => "Matrix: Must be square for inversion.",
280
- matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
281
- matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
282
- };
283
-
284
- // src/common/index.ts
285
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
286
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
287
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
288
- return DFSOperation2;
289
- })(DFSOperation || {});
290
- var Range = class {
291
- constructor(low, high, includeLow = true, includeHigh = true) {
292
- this.low = low;
293
- this.high = high;
294
- this.includeLow = includeLow;
295
- this.includeHigh = includeHigh;
296
- }
297
- // Determine whether a key is within the range
298
- isInRange(key, comparator) {
299
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
300
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
301
- return lowCheck && highCheck;
302
- }
303
- };
304
-
305
311
  // src/data-structures/heap/heap.ts
306
312
  var Heap = class _Heap extends IterableElementBase {
307
313
  /**
@@ -317,7 +323,7 @@ var priorityQueueTyped = (() => {
317
323
  __publicField(this, "_elements", []);
318
324
  __publicField(this, "_DEFAULT_COMPARATOR", (a, b) => {
319
325
  if (typeof a === "object" || typeof b === "object") {
320
- throw new TypeError(ERR.comparatorRequired("Heap"));
326
+ raise(TypeError, ERR.comparatorRequired("Heap"));
321
327
  }
322
328
  if (a > b) return 1;
323
329
  if (a < b) return -1;
@@ -366,6 +372,13 @@ var priorityQueueTyped = (() => {
366
372
 
367
373
 
368
374
 
375
+
376
+
377
+
378
+
379
+
380
+
381
+
369
382
 
370
383
 
371
384
 
@@ -423,7 +436,7 @@ var priorityQueueTyped = (() => {
423
436
  }
424
437
  /**
425
438
  * Insert an element.
426
- * @remarks Time O(1) amortized, Space O(1)
439
+ * @remarks Time O(log N) amortized, Space O(1)
427
440
  * @param element - Element to insert.
428
441
  * @returns True.
429
442
 
@@ -450,6 +463,13 @@ var priorityQueueTyped = (() => {
450
463
 
451
464
 
452
465
 
466
+
467
+
468
+
469
+
470
+
471
+
472
+
453
473
 
454
474
 
455
475
 
@@ -504,6 +524,13 @@ var priorityQueueTyped = (() => {
504
524
 
505
525
 
506
526
 
527
+
528
+
529
+
530
+
531
+
532
+
533
+
507
534
 
508
535
 
509
536
 
@@ -561,6 +588,12 @@ var priorityQueueTyped = (() => {
561
588
 
562
589
 
563
590
 
591
+
592
+
593
+
594
+
595
+
596
+
564
597
 
565
598
 
566
599
 
@@ -568,6 +601,34 @@ var priorityQueueTyped = (() => {
568
601
 
569
602
 
570
603
 
604
+ * @example
605
+ * // Heap with custom comparator (MaxHeap behavior)
606
+ * interface Task {
607
+ * id: number;
608
+ * priority: number;
609
+ * name: string;
610
+ * }
611
+ *
612
+ * // Custom comparator for max heap behavior (higher priority first)
613
+ * const tasks: Task[] = [
614
+ * { id: 1, priority: 5, name: 'Email' },
615
+ * { id: 2, priority: 3, name: 'Chat' },
616
+ * { id: 3, priority: 8, name: 'Alert' }
617
+ * ];
618
+ *
619
+ * const maxHeap = new Heap(tasks, {
620
+ * comparator: (a: Task, b: Task) => b.priority - a.priority
621
+ * });
622
+ *
623
+ * console.log(maxHeap.size); // 3;
624
+ *
625
+ * // Peek returns highest priority task
626
+ * const topTask = maxHeap.peek();
627
+ * console.log(topTask?.priority); // 8;
628
+ * console.log(topTask?.name); // 'Alert';
629
+ */
630
+ /**
631
+ * @deprecated Use `pop` instead. Will be removed in a future major version.
571
632
  * @example
572
633
  * // Heap with custom comparator (MaxHeap behavior)
573
634
  * interface Task {
@@ -595,6 +656,14 @@ var priorityQueueTyped = (() => {
595
656
  * console.log(topTask?.name); // 'Alert';
596
657
  */
597
658
  poll() {
659
+ return this.pop();
660
+ }
661
+ /**
662
+ * Remove and return the top element (min or max depending on comparator).
663
+ * @remarks Time O(log N) amortized, Space O(1)
664
+ * @returns The removed top element, or undefined if empty.
665
+ */
666
+ pop() {
598
667
  if (this.elements.length === 0) return;
599
668
  const value = this.elements[0];
600
669
  const last = this.elements.pop();
@@ -632,6 +701,13 @@ var priorityQueueTyped = (() => {
632
701
 
633
702
 
634
703
 
704
+
705
+
706
+
707
+
708
+
709
+
710
+
635
711
 
636
712
 
637
713
 
@@ -729,6 +805,13 @@ var priorityQueueTyped = (() => {
729
805
 
730
806
 
731
807
 
808
+
809
+
810
+
811
+
812
+
813
+
814
+
732
815
 
733
816
 
734
817
 
@@ -773,6 +856,13 @@ var priorityQueueTyped = (() => {
773
856
 
774
857
 
775
858
 
859
+
860
+
861
+
862
+
863
+
864
+
865
+
776
866
 
777
867
 
778
868
 
@@ -790,16 +880,6 @@ var priorityQueueTyped = (() => {
790
880
  clear() {
791
881
  this._elements = [];
792
882
  }
793
- /**
794
- * Replace the backing array and rebuild the heap.
795
- * @remarks Time O(N), Space O(N)
796
- * @param elements - Iterable used to refill the heap.
797
- * @returns Array of per-node results from fixing steps.
798
- */
799
- refill(elements) {
800
- this._elements = Array.from(elements);
801
- return this.fix();
802
- }
803
883
  /**
804
884
  * Check if an equal element exists in the heap.
805
885
  * @remarks Time O(N), Space O(1)
@@ -820,6 +900,13 @@ var priorityQueueTyped = (() => {
820
900
 
821
901
 
822
902
 
903
+
904
+
905
+
906
+
907
+
908
+
909
+
823
910
 
824
911
 
825
912
 
@@ -864,6 +951,13 @@ var priorityQueueTyped = (() => {
864
951
 
865
952
 
866
953
 
954
+
955
+
956
+
957
+
958
+
959
+
960
+
867
961
 
868
962
 
869
963
 
@@ -888,7 +982,7 @@ var priorityQueueTyped = (() => {
888
982
  }
889
983
  if (index < 0) return false;
890
984
  if (index === 0) {
891
- this.poll();
985
+ this.pop();
892
986
  } else if (index === this.elements.length - 1) {
893
987
  this.elements.pop();
894
988
  } else {
@@ -898,13 +992,19 @@ var priorityQueueTyped = (() => {
898
992
  }
899
993
  return true;
900
994
  }
995
+ /**
996
+ * @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
997
+ */
998
+ deleteBy(predicate) {
999
+ return this.deleteWhere(predicate);
1000
+ }
901
1001
  /**
902
1002
  * Delete the first element that matches a predicate.
903
1003
  * @remarks Time O(N), Space O(1)
904
1004
  * @param predicate - Function (element, index, heap) → boolean.
905
1005
  * @returns True if an element was removed.
906
1006
  */
907
- deleteBy(predicate) {
1007
+ deleteWhere(predicate) {
908
1008
  let idx = -1;
909
1009
  for (let i = 0; i < this.elements.length; i++) {
910
1010
  if (predicate(this.elements[i], i, this)) {
@@ -914,7 +1014,7 @@ var priorityQueueTyped = (() => {
914
1014
  }
915
1015
  if (idx < 0) return false;
916
1016
  if (idx === 0) {
917
- this.poll();
1017
+ this.pop();
918
1018
  } else if (idx === this.elements.length - 1) {
919
1019
  this.elements.pop();
920
1020
  } else {
@@ -954,6 +1054,13 @@ var priorityQueueTyped = (() => {
954
1054
 
955
1055
 
956
1056
 
1057
+
1058
+
1059
+
1060
+
1061
+
1062
+
1063
+
957
1064
 
958
1065
 
959
1066
 
@@ -1031,6 +1138,13 @@ var priorityQueueTyped = (() => {
1031
1138
 
1032
1139
 
1033
1140
 
1141
+
1142
+
1143
+
1144
+
1145
+
1146
+
1147
+
1034
1148
 
1035
1149
 
1036
1150
 
@@ -1081,6 +1195,13 @@ var priorityQueueTyped = (() => {
1081
1195
 
1082
1196
 
1083
1197
 
1198
+
1199
+
1200
+
1201
+
1202
+
1203
+
1204
+
1084
1205
 
1085
1206
 
1086
1207
 
@@ -1130,6 +1251,13 @@ var priorityQueueTyped = (() => {
1130
1251
 
1131
1252
 
1132
1253
 
1254
+
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+
1133
1261
 
1134
1262
 
1135
1263
 
@@ -1186,6 +1314,13 @@ var priorityQueueTyped = (() => {
1186
1314
 
1187
1315
 
1188
1316
 
1317
+
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+
1189
1324
 
1190
1325
 
1191
1326
 
@@ -1202,7 +1337,7 @@ var priorityQueueTyped = (() => {
1202
1337
  */
1203
1338
  map(callback, options, thisArg) {
1204
1339
  const { comparator, toElementFn, ...rest } = options != null ? options : {};
1205
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1340
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
1206
1341
  const out = this._createLike([], { ...rest, comparator, toElementFn });
1207
1342
  let i = 0;
1208
1343
  for (const x of this) {
@@ -1330,7 +1465,7 @@ var priorityQueueTyped = (() => {
1330
1465
  __publicField(this, "_comparator");
1331
1466
  this.clear();
1332
1467
  this._comparator = comparator || this._defaultComparator;
1333
- if (typeof this.comparator !== "function") throw new TypeError(ERR.notAFunction("comparator", "FibonacciHeap"));
1468
+ if (typeof this.comparator !== "function") raise(TypeError, ERR.notAFunction("comparator", "FibonacciHeap"));
1334
1469
  }
1335
1470
  /**
1336
1471
  * Get the circular root list head.
@@ -1367,7 +1502,7 @@ var priorityQueueTyped = (() => {
1367
1502
  * Push an element into the root list.
1368
1503
  * @remarks Time O(1) amortized, Space O(1)
1369
1504
  * @param element - Element to insert.
1370
- * @returns This heap.
1505
+ * @returns True when the element is added.
1371
1506
  */
1372
1507
  push(element) {
1373
1508
  const node = this.createNode(element);
@@ -1376,7 +1511,7 @@ var priorityQueueTyped = (() => {
1376
1511
  this.mergeWithRoot(node);
1377
1512
  if (!this.min || this.comparator(node.element, this.min.element) <= 0) this._min = node;
1378
1513
  this._size++;
1379
- return this;
1514
+ return true;
1380
1515
  }
1381
1516
  peek() {
1382
1517
  return this.min ? this.min.element : void 0;
@@ -1539,7 +1674,7 @@ var priorityQueueTyped = (() => {
1539
1674
  super(elements, {
1540
1675
  comparator: (a, b) => {
1541
1676
  if (typeof a === "object" || typeof b === "object") {
1542
- throw new TypeError(ERR.comparatorRequired("MaxHeap"));
1677
+ raise(TypeError, ERR.comparatorRequired("MaxHeap"));
1543
1678
  }
1544
1679
  if (a < b) return 1;
1545
1680
  if (a > b) return -1;
@@ -1595,7 +1730,7 @@ var priorityQueueTyped = (() => {
1595
1730
  super(elements, {
1596
1731
  comparator: (a, b) => {
1597
1732
  if (typeof a === "object" || typeof b === "object") {
1598
- throw new TypeError(ERR.comparatorRequired("MaxPriorityQueue"));
1733
+ raise(TypeError, ERR.comparatorRequired("MaxPriorityQueue"));
1599
1734
  }
1600
1735
  if (a < b) return 1;
1601
1736
  if (a > b) return -1;