Skip to content

Commit

Permalink
some nice utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nullsoepic committed Sep 24, 2024
1 parent a706dba commit 8503713
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ export class PriorityQueue<T> {
}
}

isQueued(id: string): boolean {
return this.queue.some((item) => item.id === id);
}

isProcessing(id: string): boolean {
return this.processingQueue.some((item) => item.id === id);
}

isProcessingOrQueued(id: string): boolean {
return this.isQueued(id) || this.isProcessing(id);
}

isEmpty(): boolean {
return this.queue.length === 0 && this.processingQueue.length === 0;
}
Expand Down

0 comments on commit 8503713

Please sign in to comment.