Skip to content

Commit db55a71

Browse files
committed
remove breaking change
1 parent be07d41 commit db55a71

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

lib/internal/priority_queue.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,11 @@ module.exports = class PriorityQueue {
9797
}
9898

9999
removeAt(pos) {
100-
if (pos > this.#size) return;
101-
102100
const heap = this.#heap;
103-
const size = --this.#size;
104-
heap[pos] = heap[size + 1];
105-
heap[size + 1] = undefined;
101+
let size = this.#size;
102+
heap[pos] = heap[size];
103+
heap[size] = undefined;
104+
size = --this.#size;
106105

107106
if (size > 0 && pos <= size) {
108107
if (pos > 1 && this.#compare(heap[pos >> 1], heap[pos]) > 0)

test/parallel/test-priority-queue.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ const PriorityQueue = require('internal/priority_queue');
102102
// Check that removing the last item doesn't throw
103103
queue.removeAt(6);
104104

105-
// Check that removing an item that doesn't exist doesn't throw
106-
queue.removeAt(15);
107-
108105
assert.strictEqual(queue.shift().value, 1);
109106
assert.strictEqual(queue.shift().value, 2);
110107
assert.strictEqual(queue.shift().value, 2);

0 commit comments

Comments
 (0)