npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zudojs/messaging

v1.0.0

Published

In-process message bus infrastructure with handlers, middleware, and publish/subscribe patterns.

Readme

@zudojs/messaging

In-process message bus infrastructure with handlers, middleware, and publish/subscribe patterns.

Installation

npm install @zudojs/messaging

Quick Start

import { createMessageBus } from "@zudojs/messaging";

const bus = createMessageBus();

bus.on("user.created", (message) => {
  console.log("New user:", message.payload);
});

await bus.send({
  type: "user.created",
  payload: { id: "123" },
});

bus.dispose();

Use send to build and dispatch a message from plain input, or dispatch when you already hold a Message. Both run the middleware pipeline before reaching handlers. A disposed bus rejects further use with MessageBusDisposedError.

Message identifiers

MessageId, MessageCorrelationId and MessageCausationId are branded types, so a plain string from a transport frame or a database row is not one. createMessageId() mints a new identifier; toMessageId, toCorrelationId and toCausationId brand an existing string, rejecting blank values:

import { createMessage, toMessageId, toCorrelationId } from "@zudojs/messaging";

const message = createMessage({
  id: toMessageId(frame.id),
  type: frame.type,
  payload: frame.payload,
  correlationId: toCorrelationId(frame.correlationId),
});

Middleware

use returns the id removeMiddleware takes, so middleware can be taken off again. Middleware runs in ascending priority order (default 100), with registration order breaking ties:

const id = bus.use(logging, { id: "logging", priority: 10 });
bus.use(validation, { priority: 20 });

bus.removeMiddleware(id); // true

enabled: false registers middleware without running it.

Handlers

By default a message type may have many handlers and all of them run. Pass allowMultipleHandlers: false for a command/query bus, where a second handler for the same type is a wiring mistake and is rejected at registration:

const bus = createMessageBus({ allowMultipleHandlers: false });

DispatchResult.handlerResults records every handler that ran, including the one that failed, with its real duration.

Timeouts

timeout is honoured by the dispatcher itself, so it applies whether you hold a bus or a dispatcher. On expiry the dispatch context's AbortSignal is aborted — a handler watching it can wind down — and the result carries a MessageTimeoutError:

const result = await bus.dispatch(message, { timeout: 5_000 });
if (!result.success && result.error instanceof MessageTimeoutError) {
  // …
}

createMessageBus({ defaultTimeout }) sets the default for every dispatch.

Features

  • Message bus with handler registration and dispatch
  • Middleware pipeline with priorities, removal and per-execution telemetry
  • Named message handlers with priorities
  • Optional single-handler enforcement per message type
  • Per-dispatch timeouts that abort the handler through AbortSignal
  • Correlation and causation tracking
  • Branded message identifiers

Use Cases

  • Decoupling application components
  • Event-driven workflows
  • Plugin communication
  • Background task queuing