Adds a Task to the Queue
true if succesfully added, otherwise false
Returns the number of remaining tasks.
if group is set, it will return only the remaining tasks for this group, otherwise it will return the complete amount of tasks left.
Processes the next Tasks for a group
The group the Tasks are pulled from.
A condition that, if set will be executed before the task is processed, if returns true, the task will run
The amount of tasks that should be pulled, @defaults to 1
false if thte list was empty
Removes a Task from the Queue
true if succesfully removed, otherwise false
Updates the lists in the queue depending on their priority functions and removes expired Tasks, based on their isExpired functions result.
The Group to update, if not set all groups will be updated.
Generated using TypeDoc
A Pull-TaskQueue sorted by priority and group-able Tasks by Task.group.
Sample Usage
const taskQueue = new TaskQueue({ group: ["group1"] }) taskQueue.add({ group: "group1", execute: () => { console.log("task of group1 executed"); }, getPrio: () => { return 0; } }); taskQueue.update(); taskQueue.processNext("group1");