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.

testing
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.

Named import only; this package does not export a default. TypeScript types are included.

import { ObjectQueue } from 'object-queue'

CommonJS destructuring required. The default require returns the class directly.

const { ObjectQueue } = require('object-queue')

Entry is not exported; it is an internal type. Use 'any' or define your own interface.

import { ObjectQueue } from 'object-queue'

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 footguns
gotchaDo not modify the queue while iterating over it. This can break internal links, cause infinite loops, or memory leaks.
gotchaEntries must be reference types (objects or functions). Primitive values like strings or numbers will not work and may cause unexpected behavior.
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.
breakingThe package uses a private Symbol property on objects to track links. Setting Symbol properties on frozen or proxy objects may fail.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources