Registry / devops / priority-job-queue

priority-job-queue

JSON →
library0.90.30jsnpmunverified

A lightweight client-side priority job queue module (v0.90.30) that uses a real-time ticker (every 100ms) to evaluate and run the highest-priority job. Jobs are modeled with status transitions (queued → running → complete/idle) and emit events on change. Supports serial and parallel job groups, dynamic priority changes, and scheduled/recurring jobs. Designed for browserify but also works server-side. No recent releases or significant changes since initial version.

npm install priority-job-queue
INSTALL
IMPORT
SIG · PRIORITY-JOB-QUEUE
P
priority-job-queue
devopsjavascriptv0.90.30
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PriorityJobQueue
const { PriorityJobQueue } = require('priority-job-queue');
const PriorityJobQueue = require('priority-job-queue');
CommonJS required; no ESM exports.
JobModel
const { models: { JobModel } } = require('priority-job-queue');
const JobModel = require('priority-job-queue').JobModel;
JobModel is nested under 'models' object.
createInstance
const queue = PriorityJobQueue.createInstance();
const queue = new PriorityJobQueue();
Factory method must be used; constructor is not exposed.

Creates a queue, adds a job with a simple function, starts the ticker, and stops after 500ms.

const { PriorityJobQueue } = require('priority-job-queue'); const queue = PriorityJobQueue.createInstance(); const job = queue.createJob({ description: 'example' }); job.fn = (opts, callback) => { console.log('Running job'); callback(null, 'done'); }; queue.add(job); queue.startRealTimeTicker(); setTimeout(() => { queue.stopRealTimeTicker(); }, 500);
Debug
Known issues
gotchaJobModel constructor expects an object with 'description' but other fields like 'fn' are optional and should be set after creation.
fix
Create job with createJob() or new JobModel({description: '...'}) and then assign job.fn.
affects: all
gotchaThe real-time ticker must be started explicitly via startRealTimeTicker() otherwise no jobs are executed.
fix
Call queue.startRealTimeTicker() after adding jobs.
affects: all
gotchaJob callback must be invoked; failing to call callback will keep the job in 'running' state and block the queue.
fix
Always call callback(err, result) inside job.fn.
affects: all
gotchaRemoving a job while it's running may cause undefined behavior; always check status before removal.
fix
Use queue.remove() only on queued or idle jobs.
affects: all
Errors
Common errors & fixes
TypeError: PriorityJobQueue is not a constructor
Trying to instantiate with 'new' instead of using factory method.
fix
Use PriorityJobQueue.createInstance() instead of new PriorityJobQueue().
Cannot find module 'models'
Importing JobModel directly from root without accessing models property.
fix
Use require('priority-job-queue').models.JobModel.
Job not executed: 'job.fn' is not a function
Forgetting to assign a function to the job's fn property before adding to queue.
fix
Assign job.fn = function(opts, callback) { ... } before queue.add(job).
Upgrade
Version history
0.90.30latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
priority-job-queue — npm install priority-job-queue · libregistry