MCPcopy
hub / github.com/sindresorhus/p-queue / remove

Method remove

source/priority-queue.ts:63–80  ·  view source on GitHub ↗
(idOrRun: string | RunFunction)

Source from the content-addressed store, hash-verified

61 remove(id: string): void;
62 remove(run: RunFunction): void;
63 remove(idOrRun: string | RunFunction): void {
64 const index = this.#queue.findIndex((element: Readonly<PriorityQueueOptions & {run: RunFunction}>, index) => {
65 // The consumed prefix may still contain references that should not be removable.
66 if (index < this.#head) {
67 return false;
68 }
69
70 if (typeof idOrRun === 'string') {
71 return element.id === idOrRun;
72 }
73
74 return element.run === idOrRun;
75 });
76
77 if (index !== -1) {
78 this.#queue.splice(index, 1);
79 }
80 }
81
82 dequeue(): RunFunction | undefined {
83 if (this.#head === this.#queue.length) {

Callers 2

removeQueuedTaskMethod · 0.80
priority-queue.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected