Registry / devops / pqueue

pqueue

JSON →
library0.3.1jsnpmunverified

A minimal Priority Queue implementation for Node.js and browser, offering push/top/pop operations with numeric priorities, optional custom compare function, and queue size limit. Version 0.3.1 (last release ~2012) targets Node ~0.8, no updates since, and lacks features like TypeScript types or ESM support. It is a bare-bones alternative to more modern and maintained priority queue libraries.

npm install pqueue
INSTALL
IMPORT
SIG · PQUEUE
P
pqueue
devopsjavascriptv0.3.1
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.

PriorityQueue
import { PriorityQueue } from 'pqueue'
const PriorityQueue = require('pqueue')
Package uses CommonJS exports, but named import is required for ESM. No default export.
PriorityQueue
var PriorityQueue = require('pqueue').PriorityQueue
var PriorityQueue = require('pqueue')
CommonJS users must access .PriorityQueue; the module exports an object, not the constructor directly.
push
queue.push(element, priority)
queue.push(element)
Second argument (priority) is required; if omitted, priority is undefined and breaks ordering.

Demonstrates basic usage of PriorityQueue with push() and top() operations and priority ordering.

var { PriorityQueue } = require('pqueue'); var queue = new PriorityQueue(); queue.push('urgent', 10); queue.push('normal', 5); queue.push('low', 1); console.log(queue.top()); // => 'urgent' console.log(queue.top()); // => 'normal' console.log(queue.top()); // => 'low'
Debug
Known issues
deprecatedPackage has not been updated since 2012 and targets Node ~0.8. It is effectively abandoned.
fix
Migrate to a maintained alternative like 'priorityqueue' or 'flatqueue'.
affects: <=0.3.1
gotchaThe module's main export is an object with 'PriorityQueue', not the constructor directly. Using require('pqueue') returns { PriorityQueue: [Function] }.
fix
Use var { PriorityQueue } = require('pqueue'); or require('pqueue').PriorityQueue.
affects: >=0.1.0
gotchaThe 'push' method requires a numeric priority argument; omitting it causes undefined priorities and unreliable ordering.
fix
Always provide a priority as second argument: queue.push(element, priority).
affects: >=0.1.0
gotchaThe package has no TypeScript type definitions. Use with TypeScript requires manual type declarations.
fix
Add a .d.ts file: declare module 'pqueue' { export class PriorityQueue { push(element: any, priority: number): void; top(): any; pop(): any; } }
affects: >=0.1.0
gotchaThe package does not support ESM imports natively; it is CommonJS only. Using import may fail in ESM environments.
fix
Use dynamic import or configure bundler to handle CommonJS modules.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: queue.top is not a function
Incorrect import: require('pqueue') returns an object, not the constructor.
fix
Use var { PriorityQueue } = require('pqueue'); then new PriorityQueue().
Error: Cannot find module 'pqueue'
Package not installed or not present in node_modules.
fix
Run npm install pqueue. Note: package is abandoned and may not install on modern Node versions without --legacy-peer-deps.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
packagepqueue
pqueue — npm install pqueue · libregistry