Registry / development / queue-typed

queue-typed

JSON →
library2.6.0jsnpmunverified

A high-performance Queue data structure with O(1) enqueue, dequeue, and access operations. Version 2.6.0 is stable and actively maintained as part of the data-structure-typed family. Unlike JavaScript's native Array (O(n) shift) and other queues (O(n) access), Queue Typed provides constant-time operations across all queue operations. Ships TypeScript definitions. Recommended for large-scale FIFO processing where performance matters.

npm install queue-typed
INSTALL
IMPORT
SIG · QUEUE-TYPED
Q
queue-typed
developmentjavascriptv2.6.0
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.

Queue
import { Queue } from 'queue-typed'
import Queue from 'queue-typed'
Named export only. Default import does not work.
Queue (CommonJS)
const { Queue } = require('queue-typed')
const Queue = require('queue-typed')
Must destructure the named export.
Queue type
import type { Queue } from 'queue-typed'
For type-only imports, use import type. The package ships TypeScript types.
Deque
import { Deque } from 'queue-typed'
import { Dequeue } from 'queue-typed'
Deque is also exported from the package, but the spelling is 'Deque' not 'Dequeue'.

Create a queue, enqueue 1000 numbers, dequeue them, then access by index to demonstrate O(1) performance.

import { Queue } from 'queue-typed'; const queue = new Queue<number>(); const magnitude = 1000; for (let i = 0; i < magnitude; i++) { queue.enqueue(i); } for (let i = 0; i < magnitude; i++) { const item = queue.dequeue(); console.log(item); } for (let i = 0; i < magnitude; i++) { console.log(queue.getAt(i)); // 0, 1, 2, ... }
Debug
Known issues
gotchaQueue.getAt(index) returns the value at the given index but does NOT dequeue it. It is a constant-time access.
fix
Use queue.dequeue() to remove and return the front element.
affects: >=2.0.0
gotchaWhen constructing with an initial array, the order is as-inserted (FIFO). The first element of the array is the front of the queue.
fix
new Queue([1,2,3]) results in queue with front=1, rear=3.
affects: >=2.0.0
deprecatedThe method `offer` is not part of this library; only `enqueue` is available for adding elements.
fix
Use `queue.enqueue(item)` instead.
affects: >=2.0.0
gotchaCommonJS `require` must destructure the named export. `const Queue = require('queue-typed')` will set Queue to an object, not the constructor.
fix
Use `const { Queue } = require('queue-typed')`
affects: >=2.0.0
deprecatedThe package is ESM-only starting from v3+. The `require()` syntax may not work in older Node versions if the package is updated.
fix
Use ES module imports or downgrade to v2.x if CommonJS is required.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: Queue is not a constructor
Default import used but Queue is a named export.
fix
import { Queue } from 'queue-typed'
TypeError: queue.offer is not a function
The method 'offer' does not exist; use 'enqueue'.
fix
queue.enqueue(item)
TypeError: Cannot read properties of undefined (reading 'enqueue')
Destructured incorrectly in CommonJS.
fix
const { Queue } = require('queue-typed')
ERR_REQUIRE_ESM
Package is ESM-only in version >=3.x, but code uses require().
fix
Use import statement or downgrade to 2.x
TS2307: Cannot find module 'queue-typed' or its corresponding type declarations.
TypeScript may not resolve types; ensure tsconfig.json has 'moduleResolution': 'node' or 'node16'.
fix
Set 'moduleResolution': 'node16' in tsconfig.json
Upgrade
Version history
2.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
43 hits · last 30 days
node
38
OpenAI (training)
1
Resources
queue-typed — npm install queue-typed · libregistry