job-schedule
Schedule job for run one time.
This is similar to PriorityQueue
Creates a queue object with the specified concurrency. Tasks added to the queue are processed in parallel (up to the concurrency limit). If all workers are in progress, the task is queued until one becomes available. Once a worker completes a task, that task's callback is called.
However, it can specific running-condition for the task. This is very useful to schedule the time based jobs for run one time only.
Install
$ npm i -S job-schedule
API
// parameters and return value if similar to `priorityQueue`let q = worker concurrency // Start task when this function returns `true`// Call `cb` to resume the queue `q`q { if return true } // remove jobs with condition// true: removing jobq
Example
const Queue = var timerId = nullvar q = { console } 1 // node: { priority, data }q { // start task if it's priority less than 2 if nodepriority -- < 2 console return true // resume queue after 1s timerId = } // call when all tasks finishedq { console} // add some items to the queueqq // add some items to the queue (batch-wise)q