Registry / messaging / mqemitter

mqemitter

JSON →
library7.1.0jsnpmunverified

MQEmitter is an opinionated message queue with an emitter-style API using callbacks, designed for Node.js. Current stable version is 7.1.0, requiring Node >=20. It supports topic matching with wildcards (+ and #) and configurable concurrency. Ships TypeScript definitions. Alternatives include Redis, MongoDB, and child-process backends. Good for in-process pub/sub with backpressure handling.

npm install mqemitter
INSTALL
IMPORT
SIG · MQEMITTER
M
mqemitter
messagingjavascriptv7.1.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
import mq from 'mqemitter'
const mq = require('mqemitter')
ESM-only since v7; CommonJS require() is not supported. Use import or dynamic import.
MQEmitter
import { MQEmitter } from 'mqemitter'
import MQEmitter from 'mqemitter'
Named export for class usage; default import is factory function.
MQEmitter type
import type { MQEmitter } from 'mqemitter'
import { MQEmitter } from 'mqemitter'
Use type import for TypeScript type-only usage to avoid runtime overhead.

Shows ESM import, creating an emitter with concurrency limit, subscribing to a topic, emitting a message, and closing the emitter.

import mq from 'mqemitter'; const emitter = mq({ concurrency: 5 }); emitter.on('hello/world', (msg, cb) => { console.log(msg); cb(); }); const message = { topic: 'hello/world', payload: 'data' }; emitter.emit(message, () => { console.log('message emitted'); }); setTimeout(() => emitter.close(() => process.exit(0)), 100);
Debug
Known issues
breakingmqemitter dropped CommonJS support in v7. require() will throw.
fix
Switch to ESM imports (import mq from 'mqemitter') or use dynamic import().
affects: >=7.0.0
breakingMinimum Node.js version increased to 20 in v7.
fix
Upgrade Node.js to version 20 or later.
affects: >=7.0.0
deprecatedCalling mq() without 'new' still works but is deprecated; always use new MQEmitter() or the factory function explicitly.
fix
Use 'new MQEmitter()' or just 'mq()' as factory (both create instance).
affects: >=1.0.0
gotchaListener callback 'done' must never be called with an Error; MQEmitter ignores errors and undefined behavior may occur.
fix
Always call cb() with no argument or null.
affects: >=0.0.0
gotchaemit callback is never called with an error; errors are silently ignored.
fix
Do not rely on error handling in emit callback; validate messages before emitting.
affects: >=0.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/node_modules/mqemitter/index.js from /path/app.js not supported.
Using CommonJS require() on an ESM-only package (mqemitter v7+).
fix
Convert your project to ESM or use dynamic import: const mq = await import('mqemitter');
TypeError: mq is not a function
Using default import with TypeScript but without esModuleInterop or proper import.
fix
Ensure you use 'import mq from 'mqemitter'' and have esModuleInterop enabled in tsconfig.json.
TypeError: done is not a function
Inside listener, 'done' is the second argument, but you called it with an argument or misplaced.
fix
Check listener signature: (message, done) => ... and call done() with no error.
Upgrade
Version history
7.1.0latest on npm
Audit
Dependencies
qlobberrequiredtopic matching engine used internally for wildcard subscriptions
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
mqemitter — npm install mqemitter · libregistry