a queue to ensure async functions are called one after another in order, with option to run some functions in parallel
TaskQueue17 has one main method: #push(fn[, group])
It is a async function which expects an async function, describing the task, as its first parameter.
The second parameter is a group identifier.
Normally all tasks in the queue will run sequentially.
But consecutive tasks with the same (===) group will be running in parallel.
If no group is specified, null is assumed.
A null group will always run on its own.
You can pause the queue with #pause() and resume it with #resume().
You can get the current pause-state with #isPaused().
The queue starts unpaused.
constTaskQueue=require('taskqueue17')consttaskQueue=newTaskQueue()consttaskA=taskQueue.push(async()=>{console.log('I run alone! (1)')})consttaskB=taskQueue.push(async()=>{console.log('We run together! (2)')},0)consttaskC=taskQueue.push(async()=>{console.log('We run together! (3)')},0)consttaskD=taskQueue.push(async()=>{console.log('I run alone! (4)')})Promise.all([taskA,taskB,taskC,taskD]).then(()=>{console.log('All tasks done!')}).catch(error=>{console.error('At least one task failed!',error)})