Registry / messaging / consume-queue

consume-queue

JSON →
library0.1.0jsnpmunverified

A simple message queue library for Node.js with produce/consume pattern. Version 0.1.0 provides basic in-process message queuing where a producer can push a message and get a promise-based receipt that resolves when a consumer acknowledges the message. The library is minimal (single function returning an object with `produce` and `consume` methods). It uses UUID for message IDs and timestamps. No external dependencies. The project appears to be in early development (v0.1.0) with no recent releases, no TypeScript definitions, and no documentation on concurrency, persistence, or error handling. It is mainly useful for simple in-memory async workflows.

npm install consume-queue
INSTALL
IMPORT
SIG · CONSUME-QUEUE
C
consume-queue
messagingjavascriptv0.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
const messageQueue = require('consume-queue')
import messageQueue from 'consume-queue'
CJS-only; no ESM exports. Named exports are not available.
produce
const { produce } = messageQueue()
const { produce } = require('consume-queue')
produce is a method of the queue instance, not a static import.
consume
const { consume } = messageQueue()
const { consume } = require('consume-queue')
Same as produce; consume is a method of the queue instance.

Shows basic usage: create a queue, produce a message, then consume it with a callback, and handle the receipt promise.

const messageQueue = require('consume-queue'); const { produce, consume } = messageQueue(); const { receipt, message } = produce({ a: 1 }); console.log(message); // { id: '...', source: { a: 1 }, time: 1234567890123 } // Simulate async consumer callback setTimeout(() => { consume({ id: message.id, data: 'ok!' }); }, 100); receipt.then((ret) => { console.log(ret); // 'ok!' });
Debug
Known issues
gotchaproduce and consume are methods of the queue instance, not exported directly from the package.
fix
Call messageQueue() to get the queue instance, then destructure produce and consume.
affects: >=0.0.0
gotchaThe consume function must provide an object with `id` and `data` properties.
fix
Ensure the argument to consume is `{ id: message.id, data: '...' }`. It does not accept separate arguments.
affects: >=0.0.0
gotchaThe package has no TypeScript definitions and is not designed for ESM.
fix
Use CommonJS require. For TypeScript, create a declaration file or use `require('consume-queue')` with `allowSyntheticDefaultImports`.
affects: >=0.0.0
gotchaVersion 0.1.0 is alpha; no breaking changes documented but API may change in future releases.
fix
Pin exact version in package.json.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: messageQueue is not a function
Using import statement instead of require, or forgetting to call messageQueue() as a function.
fix
Use `const messageQueue = require('consume-queue'); const queue = messageQueue();`
Cannot find module 'consume-queue'
Package not installed or incorrect import path.
fix
Run `npm install consume-queue --save` and ensure node_modules is present.
ReferenceError: produce is not defined
Destructuring produce from the package instead of from the queue instance.
fix
Correct: `const { produce } = messageQueue();`
TypeError: receipt.then is not a function
Forgot to call produce, so receipt is undefined.
fix
Ensure you call produce() and store the result: `const { receipt } = produce({a:1});`
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
35 hits · last 30 days
node
34
OpenAI (training)
1
Resources
consume-queue — npm install consume-queue · libregistry