Registry / storage / queue.io

queue.io

JSON →
library2.3.0jsnpmunverified

Event-based queue iteration library for JavaScript (v2.3.0). Allows creating asynchronously filled queues from event emitters or iterables, then iterating over them with forward/backward directions. Supports appending, prepending (listen), and intercepting queues. Key differentiator: queues can be populated before or after iterators are created, and multiple independent iterators can traverse the same queue in different directions. Depends on Node.js EventEmitter. Not heavily maintained (last update years ago).

npm install queue.io
INSTALL
IMPORT
SIG · QUEUE.IO
Q
queue.io
storagejavascriptv2.3.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.io'
✗ const Queue = require('queue.io')
Default export; ESM import preferred.
Queue
✓ const Queue = require('queue.io').default
✗ const Queue = require('queue.io')
In CommonJS, the default export is accessed via .default.
Queue.NEXT
✓ import Queue from 'queue.io'; Queue.NEXT
✗ import { NEXT } from 'queue.io'
NEXT and PREV are static properties on the Queue class, not named exports.

Creates a queue from an EventEmitter, pushes values, then iterates forward consuming until done.

import Queue from 'queue.io'; import { EventEmitter } from 'events'; const emitter = new EventEmitter(); const queue = Queue(emitter, 'value'); emitter.emit('value', 1); emitter.emit('value', 2); emitter.emit('value', 3); emitter.emit('done'); const iterator = queue.iterate(); iterator.on('value', (data) => { console.log('Value:', data.value); if (data.value < 3) { data.next(); } }); iterator.on('done', () => { console.log('Iteration done'); });
Debug
Known issues
deprecatedThe package uses an older EventEmitter pattern; consider using async iterators for modern code.
fix
Use native async iteration with for-await-of or libraries like iter-ops.
affects: >=0.0.0
gotchaQueue.from does not accept generic iterables (only array-like objects). Passing a Set or Map may not work as expected.
fix
Convert iterables to arrays first: Queue.from([...set]).
affects: >=2.0.0
gotchaIf no eventEmitter is provided, the queue auto-dones at next tick only if no queues are joined via intercept/listen/append. This can cause premature done if not joined.
fix
Always provide an eventEmitter or use Queue.from to avoid unexpected done.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: queue.iterate is not a function
Importing incorrectly in ESM or CJS environment.
fix
Ensure you are using the default export: import Queue from 'queue.io' then call Queue() to create a queue.
Uncaught TypeError: Cannot read properties of undefined (reading 'on')
Calling iterator.on before queue has been filled and done.
fix
Call iterate() only after the queue is done, or ensure events are listened after iterator creation.
Error: done event must be emitted on the eventEmitter
Forgetting to emit 'done' on the eventEmitter when using custom emitter.
fix
Emit emitter.emit('done') after all values are pushed.
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies
eventsoptionalUses Node.js EventEmitter as optional event source
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
queue.io — npm install queue.io · libregistry