Comparing version
@@ -62,9 +62,11 @@ "use strict"; | ||
cancelTasks(key) { | ||
const isCanceledItem = (item) => item.key === key; | ||
const canceledItems = this._queue.filter((item) => isCanceledItem(item)); | ||
this._queue = this._queue.filter((item) => !isCanceledItem(item)); | ||
if (this._currentTask && isCanceledItem(this._currentTask)) { | ||
const shouldCancelItem = (item) => item.key === key; | ||
const itemsToCancel = this._queue.filter((item) => shouldCancelItem(item)); | ||
this._queue = this._queue.filter((item) => !shouldCancelItem(item)); | ||
const canceledItems = []; | ||
if (this._currentTask && shouldCancelItem(this._currentTask)) { | ||
canceledItems.push(this._currentTask); | ||
this._currentTaskAbortController?.abort(); | ||
} | ||
canceledItems.forEach((item) => { | ||
itemsToCancel.forEach((item) => { | ||
let abortController; | ||
@@ -77,2 +79,3 @@ try { | ||
} | ||
canceledItems.push(item); | ||
abortController?.abort(); | ||
@@ -79,0 +82,0 @@ try { |
{ | ||
"name": "suprqueue", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "Simple in-memory promise-based task queue with support for pausing, merging tasks, or retrying failed tasks", | ||
@@ -5,0 +5,0 @@ "main": "dist/Suprqueue.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
190055
0.14%4055
0.07%