max-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 +207 -71
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +206 -70
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +207 -72
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +206 -71
  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/max-priority-queue-typed.js +204 -69
  39. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  40. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  41. package/dist/umd/max-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
@@ -30,9 +30,61 @@ var maxPriorityQueueTyped = (() => {
30
30
  Heap: () => Heap,
31
31
  MaxPriorityQueue: () => MaxPriorityQueue,
32
32
  PriorityQueue: () => PriorityQueue,
33
- Range: () => Range
33
+ Range: () => Range,
34
+ raise: () => raise
34
35
  });
35
36
 
37
+ // src/common/error.ts
38
+ function raise(ErrorClass, message) {
39
+ throw new ErrorClass(message);
40
+ }
41
+ var ERR = {
42
+ // Range / index
43
+ indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
44
+ invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
45
+ // Type / argument
46
+ invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
47
+ comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
48
+ invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
49
+ notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
50
+ invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
51
+ invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
52
+ invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
53
+ reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
54
+ callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
55
+ // State / operation
56
+ invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
57
+ // Matrix
58
+ matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
59
+ matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
60
+ matrixNotSquare: () => "Matrix: Must be square for inversion.",
61
+ matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
62
+ matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
63
+ // Order statistic
64
+ orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
65
+ };
66
+
67
+ // src/common/index.ts
68
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
69
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
70
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
71
+ return DFSOperation2;
72
+ })(DFSOperation || {});
73
+ var Range = class {
74
+ constructor(low, high, includeLow = true, includeHigh = true) {
75
+ this.low = low;
76
+ this.high = high;
77
+ this.includeLow = includeLow;
78
+ this.includeHigh = includeHigh;
79
+ }
80
+ // Determine whether a key is within the range
81
+ isInRange(key, comparator) {
82
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
83
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
84
+ return lowCheck && highCheck;
85
+ }
86
+ };
87
+
36
88
  // src/data-structures/base/iterable-element-base.ts
37
89
  var IterableElementBase = class {
38
90
  /**
@@ -55,7 +107,7 @@ var maxPriorityQueueTyped = (() => {
55
107
  if (options) {
56
108
  const { toElementFn } = options;
57
109
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
58
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
110
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
59
111
  }
60
112
  }
61
113
  /**
@@ -211,7 +263,7 @@ var maxPriorityQueueTyped = (() => {
211
263
  acc = initialValue;
212
264
  } else {
213
265
  const first = iter.next();
214
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
266
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
215
267
  acc = first.value;
216
268
  index = 1;
217
269
  }
@@ -253,52 +305,6 @@ var maxPriorityQueueTyped = (() => {
253
305
  }
254
306
  };
255
307
 
256
- // src/common/error.ts
257
- var ERR = {
258
- // Range / index
259
- indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
260
- invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
261
- // Type / argument
262
- invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
263
- comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
264
- invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
265
- notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
266
- invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
267
- invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
268
- invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
269
- reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
270
- callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
271
- // State / operation
272
- invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
273
- // Matrix
274
- matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
275
- matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
276
- matrixNotSquare: () => "Matrix: Must be square for inversion.",
277
- matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
278
- matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
279
- };
280
-
281
- // src/common/index.ts
282
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
283
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
284
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
285
- return DFSOperation2;
286
- })(DFSOperation || {});
287
- var Range = class {
288
- constructor(low, high, includeLow = true, includeHigh = true) {
289
- this.low = low;
290
- this.high = high;
291
- this.includeLow = includeLow;
292
- this.includeHigh = includeHigh;
293
- }
294
- // Determine whether a key is within the range
295
- isInRange(key, comparator) {
296
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
297
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
298
- return lowCheck && highCheck;
299
- }
300
- };
301
-
302
308
  // src/data-structures/heap/heap.ts
303
309
  var Heap = class _Heap extends IterableElementBase {
304
310
  /**
@@ -314,7 +320,7 @@ var maxPriorityQueueTyped = (() => {
314
320
  __publicField(this, "_elements", []);
315
321
  __publicField(this, "_DEFAULT_COMPARATOR", (a, b) => {
316
322
  if (typeof a === "object" || typeof b === "object") {
317
- throw new TypeError(ERR.comparatorRequired("Heap"));
323
+ raise(TypeError, ERR.comparatorRequired("Heap"));
318
324
  }
319
325
  if (a > b) return 1;
320
326
  if (a < b) return -1;
@@ -363,6 +369,13 @@ var maxPriorityQueueTyped = (() => {
363
369
 
364
370
 
365
371
 
372
+
373
+
374
+
375
+
376
+
377
+
378
+
366
379
 
367
380
 
368
381
 
@@ -420,7 +433,7 @@ var maxPriorityQueueTyped = (() => {
420
433
  }
421
434
  /**
422
435
  * Insert an element.
423
- * @remarks Time O(1) amortized, Space O(1)
436
+ * @remarks Time O(log N) amortized, Space O(1)
424
437
  * @param element - Element to insert.
425
438
  * @returns True.
426
439
 
@@ -447,6 +460,13 @@ var maxPriorityQueueTyped = (() => {
447
460
 
448
461
 
449
462
 
463
+
464
+
465
+
466
+
467
+
468
+
469
+
450
470
 
451
471
 
452
472
 
@@ -501,6 +521,13 @@ var maxPriorityQueueTyped = (() => {
501
521
 
502
522
 
503
523
 
524
+
525
+
526
+
527
+
528
+
529
+
530
+
504
531
 
505
532
 
506
533
 
@@ -558,6 +585,12 @@ var maxPriorityQueueTyped = (() => {
558
585
 
559
586
 
560
587
 
588
+
589
+
590
+
591
+
592
+
593
+
561
594
 
562
595
 
563
596
 
@@ -565,6 +598,34 @@ var maxPriorityQueueTyped = (() => {
565
598
 
566
599
 
567
600
 
601
+ * @example
602
+ * // Heap with custom comparator (MaxHeap behavior)
603
+ * interface Task {
604
+ * id: number;
605
+ * priority: number;
606
+ * name: string;
607
+ * }
608
+ *
609
+ * // Custom comparator for max heap behavior (higher priority first)
610
+ * const tasks: Task[] = [
611
+ * { id: 1, priority: 5, name: 'Email' },
612
+ * { id: 2, priority: 3, name: 'Chat' },
613
+ * { id: 3, priority: 8, name: 'Alert' }
614
+ * ];
615
+ *
616
+ * const maxHeap = new Heap(tasks, {
617
+ * comparator: (a: Task, b: Task) => b.priority - a.priority
618
+ * });
619
+ *
620
+ * console.log(maxHeap.size); // 3;
621
+ *
622
+ * // Peek returns highest priority task
623
+ * const topTask = maxHeap.peek();
624
+ * console.log(topTask?.priority); // 8;
625
+ * console.log(topTask?.name); // 'Alert';
626
+ */
627
+ /**
628
+ * @deprecated Use `pop` instead. Will be removed in a future major version.
568
629
  * @example
569
630
  * // Heap with custom comparator (MaxHeap behavior)
570
631
  * interface Task {
@@ -592,6 +653,14 @@ var maxPriorityQueueTyped = (() => {
592
653
  * console.log(topTask?.name); // 'Alert';
593
654
  */
594
655
  poll() {
656
+ return this.pop();
657
+ }
658
+ /**
659
+ * Remove and return the top element (min or max depending on comparator).
660
+ * @remarks Time O(log N) amortized, Space O(1)
661
+ * @returns The removed top element, or undefined if empty.
662
+ */
663
+ pop() {
595
664
  if (this.elements.length === 0) return;
596
665
  const value = this.elements[0];
597
666
  const last = this.elements.pop();
@@ -629,6 +698,13 @@ var maxPriorityQueueTyped = (() => {
629
698
 
630
699
 
631
700
 
701
+
702
+
703
+
704
+
705
+
706
+
707
+
632
708
 
633
709
 
634
710
 
@@ -726,6 +802,13 @@ var maxPriorityQueueTyped = (() => {
726
802
 
727
803
 
728
804
 
805
+
806
+
807
+
808
+
809
+
810
+
811
+
729
812
 
730
813
 
731
814
 
@@ -770,6 +853,13 @@ var maxPriorityQueueTyped = (() => {
770
853
 
771
854
 
772
855
 
856
+
857
+
858
+
859
+
860
+
861
+
862
+
773
863
 
774
864
 
775
865
 
@@ -787,16 +877,6 @@ var maxPriorityQueueTyped = (() => {
787
877
  clear() {
788
878
  this._elements = [];
789
879
  }
790
- /**
791
- * Replace the backing array and rebuild the heap.
792
- * @remarks Time O(N), Space O(N)
793
- * @param elements - Iterable used to refill the heap.
794
- * @returns Array of per-node results from fixing steps.
795
- */
796
- refill(elements) {
797
- this._elements = Array.from(elements);
798
- return this.fix();
799
- }
800
880
  /**
801
881
  * Check if an equal element exists in the heap.
802
882
  * @remarks Time O(N), Space O(1)
@@ -817,6 +897,13 @@ var maxPriorityQueueTyped = (() => {
817
897
 
818
898
 
819
899
 
900
+
901
+
902
+
903
+
904
+
905
+
906
+
820
907
 
821
908
 
822
909
 
@@ -861,6 +948,13 @@ var maxPriorityQueueTyped = (() => {
861
948
 
862
949
 
863
950
 
951
+
952
+
953
+
954
+
955
+
956
+
957
+
864
958
 
865
959
 
866
960
 
@@ -885,7 +979,7 @@ var maxPriorityQueueTyped = (() => {
885
979
  }
886
980
  if (index < 0) return false;
887
981
  if (index === 0) {
888
- this.poll();
982
+ this.pop();
889
983
  } else if (index === this.elements.length - 1) {
890
984
  this.elements.pop();
891
985
  } else {
@@ -895,13 +989,19 @@ var maxPriorityQueueTyped = (() => {
895
989
  }
896
990
  return true;
897
991
  }
992
+ /**
993
+ * @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
994
+ */
995
+ deleteBy(predicate) {
996
+ return this.deleteWhere(predicate);
997
+ }
898
998
  /**
899
999
  * Delete the first element that matches a predicate.
900
1000
  * @remarks Time O(N), Space O(1)
901
1001
  * @param predicate - Function (element, index, heap) → boolean.
902
1002
  * @returns True if an element was removed.
903
1003
  */
904
- deleteBy(predicate) {
1004
+ deleteWhere(predicate) {
905
1005
  let idx = -1;
906
1006
  for (let i = 0; i < this.elements.length; i++) {
907
1007
  if (predicate(this.elements[i], i, this)) {
@@ -911,7 +1011,7 @@ var maxPriorityQueueTyped = (() => {
911
1011
  }
912
1012
  if (idx < 0) return false;
913
1013
  if (idx === 0) {
914
- this.poll();
1014
+ this.pop();
915
1015
  } else if (idx === this.elements.length - 1) {
916
1016
  this.elements.pop();
917
1017
  } else {
@@ -951,6 +1051,13 @@ var maxPriorityQueueTyped = (() => {
951
1051
 
952
1052
 
953
1053
 
1054
+
1055
+
1056
+
1057
+
1058
+
1059
+
1060
+
954
1061
 
955
1062
 
956
1063
 
@@ -1028,6 +1135,13 @@ var maxPriorityQueueTyped = (() => {
1028
1135
 
1029
1136
 
1030
1137
 
1138
+
1139
+
1140
+
1141
+
1142
+
1143
+
1144
+
1031
1145
 
1032
1146
 
1033
1147
 
@@ -1078,6 +1192,13 @@ var maxPriorityQueueTyped = (() => {
1078
1192
 
1079
1193
 
1080
1194
 
1195
+
1196
+
1197
+
1198
+
1199
+
1200
+
1201
+
1081
1202
 
1082
1203
 
1083
1204
 
@@ -1127,6 +1248,13 @@ var maxPriorityQueueTyped = (() => {
1127
1248
 
1128
1249
 
1129
1250
 
1251
+
1252
+
1253
+
1254
+
1255
+
1256
+
1257
+
1130
1258
 
1131
1259
 
1132
1260
 
@@ -1183,6 +1311,13 @@ var maxPriorityQueueTyped = (() => {
1183
1311
 
1184
1312
 
1185
1313
 
1314
+
1315
+
1316
+
1317
+
1318
+
1319
+
1320
+
1186
1321
 
1187
1322
 
1188
1323
 
@@ -1199,7 +1334,7 @@ var maxPriorityQueueTyped = (() => {
1199
1334
  */
1200
1335
  map(callback, options, thisArg) {
1201
1336
  const { comparator, toElementFn, ...rest } = options != null ? options : {};
1202
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1337
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
1203
1338
  const out = this._createLike([], { ...rest, comparator, toElementFn });
1204
1339
  let i = 0;
1205
1340
  for (const x of this) {
@@ -1327,7 +1462,7 @@ var maxPriorityQueueTyped = (() => {
1327
1462
  __publicField(this, "_comparator");
1328
1463
  this.clear();
1329
1464
  this._comparator = comparator || this._defaultComparator;
1330
- if (typeof this.comparator !== "function") throw new TypeError(ERR.notAFunction("comparator", "FibonacciHeap"));
1465
+ if (typeof this.comparator !== "function") raise(TypeError, ERR.notAFunction("comparator", "FibonacciHeap"));
1331
1466
  }
1332
1467
  /**
1333
1468
  * Get the circular root list head.
@@ -1364,7 +1499,7 @@ var maxPriorityQueueTyped = (() => {
1364
1499
  * Push an element into the root list.
1365
1500
  * @remarks Time O(1) amortized, Space O(1)
1366
1501
  * @param element - Element to insert.
1367
- * @returns This heap.
1502
+ * @returns True when the element is added.
1368
1503
  */
1369
1504
  push(element) {
1370
1505
  const node = this.createNode(element);
@@ -1373,7 +1508,7 @@ var maxPriorityQueueTyped = (() => {
1373
1508
  this.mergeWithRoot(node);
1374
1509
  if (!this.min || this.comparator(node.element, this.min.element) <= 0) this._min = node;
1375
1510
  this._size++;
1376
- return this;
1511
+ return true;
1377
1512
  }
1378
1513
  peek() {
1379
1514
  return this.min ? this.min.element : void 0;
@@ -1545,7 +1680,7 @@ var maxPriorityQueueTyped = (() => {
1545
1680
  super(elements, {
1546
1681
  comparator: (a, b) => {
1547
1682
  if (typeof a === "object" || typeof b === "object") {
1548
- throw new TypeError(ERR.comparatorRequired("MaxPriorityQueue"));
1683
+ raise(TypeError, ERR.comparatorRequired("MaxPriorityQueue"));
1549
1684
  }
1550
1685
  if (a < b) return 1;
1551
1686
  if (a > b) return -1;