Registry / testing / emitter-queue

emitter-queue

JSON →
library1.0.0jsnpmunverified

Queue events from an event emitter until a listener is attached. Version 1.0.0 is the latest stable release. This module allows emitting events before any listener is registered, queuing them until a matching 'on' handler is added. Works with Node.js EventEmitter and the component/emitter library. Useful for initialization sequences where events fire before listeners are set up. Minimal API with a single method 'queue'.

npm install emitter-queue
INSTALL
IMPORT
SIG · EMITTER-QUEUE
E
emitter-queue
testingjavascriptv1.0.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.

default
const queue = require('emitter-queue')
import queue from 'emitter-queue'
This package does not ship an ES module; use CommonJS require.
default
import queue from 'emitter-queue'
const { queue } = require('emitter-queue')
The module exports a single function, not a named export. ES import works if bundler handles CommonJS interop.

Shows how to create a queue-enabled emitter, queue events before a listener is attached, and then attach a listener to receive queued events.

const queue = require('emitter-queue'); const EventEmitter = require('events'); const emitter = new EventEmitter(); queue(emitter); // Queue events before listeners emitter.queue('message', 'hello'); emitter.queue('message', 'world'); // Attach listener - queued events are emitted immediately emitter.on('message', (val) => { console.log(val); }); // Output: hello // Output: world
Debug
Known issues
gotchaThe queue() method is added to the emitter object. Calling queue() without wrapping the emitter first will throw an error.
fix
Ensure you call queue(emitter) on the emitter instance before calling emitter.queue().
affects: >=0.0.0
gotchaQueued events are only emitted once when a listener is attached. If no listener is ever attached, queued events are silently lost.
fix
Always attach a listener via emitter.on() or emitter.once() to receive queued events, or ensure events are emitted after listeners are attached.
affects: >=0.0.0
gotchaEvent names are case-sensitive. Queuing 'event' and listening for 'Event' will not trigger the handler.
fix
Use consistent event name casing.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: emitter.queue is not a function
The emitter was not wrapped with queue() before calling queue().
fix
const queue = require('emitter-queue'); queue(emitter);
Cannot find module 'emitter-queue'
Package not installed or import path incorrect.
fix
Run 'npm install emitter-queue' and use require('emitter-queue').
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
emitter-queue — npm install emitter-queue · libregistry