A type-safe, async-friendly, queue-based event emitter for Node.js and TypeScript.
EventQue is a fully type-safe, Promise-based event emitter designed for Node.js and TypeScript.
It supports queued event emission with ordered processing, parallel or sequential listener execution, timeout control, and AbortSignal cancellation.
on, once, off)Automatically generated using TypeDoc.
npm install eventque
interface MyEvents {
log: [string]
compute: [number, number]
}
import { EventQue } from 'eventque'
const emitter = new EventQue<MyEvents>({
defaultOptions: {
parallel: false,
timeoutMs: 2000,
},
perEventOptions: {
compute: {
parallel: true,
timeoutMs: 5000,
},
},
})
emitter.on('log', (message, signal) => {
if (signal.aborted) return
console.log('Log:', message)
})
emitter.once('compute', async (a, b, signal) => {
if (signal.aborted) throw new Error('Cancelled')
await new Promise((res) => setTimeout(res, 1000))
return a + b
})
await emitter.emitAsync('log', 'Hello EventQue!')
const results = await emitter.emitAsync('compute', 5, 7)
console.log('Compute Results:', results)
| Option | Type | Description |
|---|---|---|
parallel |
boolean | Whether to run all listeners in parallel |
stopOnError |
boolean | Stop execution on first error |
timeoutMs |
number | Per-listener timeout in milliseconds |
eventque/
├── src/
│ └── EventQue.ts
├── test/
│ └── EventQue.test.ts
├── docs/ ← Generated by TypeDoc
│ ├── index.html
│ └── ...
├── package.json
└── README.md
✅ Generate docs:
npm run docs
✅ Preview locally:
npx http-server ./docs
✅ GitHub Pages example:
https://IsamuSugi.github.io/eventque/
Use .github/workflows/gh-pages.yml:
name: Deploy Docs
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install
- run: npm run docs
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
MIT
Isamu Sugiura / GitHub: [https://github.com/isamuSugi]
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.