Registry / testing / object-queue

object-queue

JSON →
library1.0.1jsnpmunverified

A high-performance, singly linked list queue for objects that also acts as a Set. Designed for Node.js >=7.6.0, it provides O(1) operations for enqueue, dequeue, has, getNext, and delete. Entries must be reference types and are tagged with a private Symbol. The queue is iterable but not safe to modify during iteration. Version 1.0.1 is stable but has known memory leak risks if not cleared. Lightweight with zero dependencies and TypeScript definitions included.

npm install object-queue
INSTALL
IMPORT
SIG · OBJECT-QUEUE
O
object-queue
testingjavascriptv1.0.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.

ObjectQueue
import { ObjectQueue } from 'object-queue'
import ObjectQueue from 'object-queue'
Named import only; this package does not export a default. TypeScript types are included.
ObjectQueue
const { ObjectQueue } = require('object-queue')
const ObjectQueue = require('object-queue')
CommonJS destructuring required. The default require returns the class directly.
type Entry
import { ObjectQueue } from 'object-queue'
Entry is not exported; it is an internal type. Use 'any' or define your own interface.

Demonstrates creating a queue, enqueuing two objects, checking size and membership, dequeuing, and clearing. Shows TypeScript generics usage.

import { ObjectQueue } from 'object-queue'; const queue = new ObjectQueue<{ id: number }>(); const obj1 = { id: 1 }; const obj2 = { id: 2 }; console.log(queue.enqueue(obj1)); // true console.log(queue.enqueue(obj2)); // true console.log(queue.size); // 2 console.log(queue.has(obj1)); // true console.log(queue.dequeue()); // { id: 1 } console.log(queue.size); // 1 queue.clear(); console.log(queue.size); // 0
Debug
Known issues
gotchaDo not modify the queue while iterating over it. This can break internal links, cause infinite loops, or memory leaks.
fix
Collect all items in an array first (e.g., using toArray()) and then modify the queue outside the iteration.
affects: >=1.0.0
gotchaEntries must be reference types (objects or functions). Primitive values like strings or numbers will not work and may cause unexpected behavior.
fix
Wrap primitives in an object: queue.enqueue({ key: value }).
affects: >=1.0.0
gotchaIf you do not dequeue all entries or call clear(), the internal linked list references will prevent garbage collection of entries, leading to memory leaks.
fix
Always call clear() or dequeue every element when the queue is no longer needed.
affects: >=1.0.0
breakingThe package uses a private Symbol property on objects to track links. Setting Symbol properties on frozen or proxy objects may fail.
fix
Ensure entries are not frozen (Object.isFrozen) and are plain objects.
affects: >=1.0.0
Errors
Common errors & fixes
queue.enqueue('string') // returns false
Primitive values are not allowed; only objects/functions.
fix
Wrap the primitive in an object: queue.enqueue({ value: 'string' })
Error: Cannot add property <symbol>, object is not extensible
Attempting to enqueue a frozen or sealed object.
fix
Do not freeze or seal entries before enqueuing, or use a different queue implementation.
TypeError: queue.entries is not a function
ObjectQueue does not have an `entries` method like Map/Set.
fix
Use queue.toArray() or iterate via for...of (the queue is iterable).
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
object-queue — npm install object-queue · libregistry