Task Queueing - push , wait and process. All task will store in an array
$ npm install ar-queue-task
const QueueTask = require('ar-queue-task');
const queue = QueueTask.work();
queue.enqueue({
id : 1,
message : 'Hello World'
}, (data) => {
console.log(`Output: ${data.message}`);
});
// auto generated id
queue.enqueue({message : 'Hello World'}, (data) => new Promise( resolve => {
setTimeout(() => {
console.log(data.message);
resolve();
}, 1000);
}));
queue:work
queue:process TASK ID [1]
Output: Hello World
queue:done TASK ID [1]
queue:process TASK ID [16ade13e-8780-5113-9238-151e45beca60]
Hello World
queue:done TASK ID [16ade13e-8780-5113-9238-151e45beca60]
set queue configuration
Type : object
disableLogs
- disable all console logs
Type :
boolean
Default : false
adds a task to the queue
Type : object
- it must be an object and contain an optional id key to make the task unique or it will generate a uuid for the given task.
- data to be processed or passed to callback
Type: function
- the function by which the data can be processed
- please feel free to contact the author for bugs and suggestions. Thanks and keep safe!!!!