Skip to content

Commit

Permalink
#208 - throw error if undefined item in queue while setting priority
Browse files Browse the repository at this point in the history
  • Loading branch information
RaishavHanspal committed Jul 19, 2024
1 parent cafe886 commit 6a370fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/priority-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export default class PriorityQueue implements Queue<RunFunction, PriorityQueueOp

setPriority(id: string, priority: number) {
const existingIndex: number = this.#queue.findIndex((element: Readonly<PriorityQueueOptions>) => element.id === id);
if (existingIndex === -1) {
if (existingIndex === -1 ) {

Check failure on line 38 in source/priority-queue.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

There should be no space before this paren.

Check failure on line 38 in source/priority-queue.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

There should be no space before this paren.
throw new Error('Invalid Index - No promise function of specified id available in the queue.');
}

const [item] = this.#queue.splice(existingIndex, 1);
if (item === undefined) {
return;
throw new Error('Undefined Item - No promise function of specified id available in the queue.');
}

item.priority = priority;
Expand Down

0 comments on commit 6a370fe

Please sign in to comment.