Closed hastebrot closed 6 years ago
Proposed solution: Add a new option to WorkerOptions that defines a comparator:
WorkerOptions
comparator
interface WorkerOptions { comparator: (item: Task, otherItem: Task) => number }
Augment Task interface with a running index number.
Task
index
interface Task { id: any, priority?: number action?: TaskAction }
Allow to sort the tasks with (task, otherTask) => task.priority - otherTask.priority (accending), and (task, otherTask) => otherTask.priority - task.priority (decending).
(task, otherTask) => task.priority - otherTask.priority
(task, otherTask) => otherTask.priority - task.priority
Proposed solution: Add a new option to
WorkerOptions
that defines acomparator
:Augment
Task
interface with a runningindex
number.Allow to sort the tasks with
(task, otherTask) => task.priority - otherTask.priority
(accending), and(task, otherTask) => otherTask.priority - task.priority
(decending).