@abtnode/queue
v1.16.36
Published
A simple job queue built on top of [nedb](https://www.npmjs.com/package/nedb) and [fastq](https://www.npmjs.com/package/fastq)
Downloads
6,642
Readme
@abtnode/queue
A simple job queue built on top of nedb and fastq
Usage
yarn add @abtnode/queue
Then:
const createQueue = require('@abtnode/queue');
const queue = createQueue({
file: '/path/to/job.db',
onJob: (job) => {
console.log('onJob', job);
const result = someLongTask(job);
return result;
},
});
const task = queue.push({ id: 2 });
task.on('failed', ({ id, job, error }) => {
console.error('job failed', error);
});
task.on('finished', ({ id, job, result }) => {
console.log('job finished', result);
});