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

@zerotal/broadcasting

v1.7.5

Published

Real-time event broadcasting over WebSockets for Zerotal, with public/private/presence channels.

Readme

@zerotal/broadcasting

Real-time WebSocket broadcasting with a Pusher-compatible server built into your app process.

Define a BroadcastingEvent, dispatch it, and every subscribed client receives the payload over a live WebSocket connection — no separate service required. Supports public, private, and presence channels, a Redis driver for horizontally-scaled deployments, and works unchanged with any Pusher-protocol client.

Part of the Zerotal framework. Requires Bun ≥ 1.3.14.

Installation

bun add @zerotal/broadcasting

Setup

Register the provider in bootstrap/providers.ts:

import { BroadcastProvider } from "@zerotal/broadcasting";

It registers two HTTP endpoints automatically: GET /app/{appKey} (WebSocket upgrade) and POST /broadcasting/auth (private/presence channel auth).

Usage

Write a broadcast event — only broadcastOn() is required:

import { BroadcastingEvent, privateChannel } from "@zerotal/broadcasting";

export class OrderShipmentStatusUpdated extends BroadcastingEvent {
  constructor(public readonly order: Order) {
    super();
  }

  broadcastOn() {
    return privateChannel(`orders.${this.order.id}`);
  }

  broadcastWith() {
    return { id: this.order.id, status: this.order.status };
  }
}

Dispatch it — static, fluent, or via the facade:

import { broadcast, Broadcast } from "@zerotal/broadcasting";

OrderShipmentStatusUpdated.dispatch(order); // construct + dispatch + broadcast
await broadcast(new OrderShipmentStatusUpdated(order)).toOthers(); // exclude current socket
Broadcast.send(new OrderShipmentStatusUpdated(order)); // explicit send

Pick a channel type with the helpers, then authorize private/presence channels in routes/channels.ts:

import { channel, privateChannel, presenceChannel } from "@zerotal/broadcasting";

channel("posts"); // public
privateChannel("orders.42"); // private  -> "private-orders.42"
presenceChannel("chat.room1"); // presence -> "presence-chat.room1"
// routes/channels.ts
import { Broadcast } from "@zerotal/broadcasting";

Broadcast.channel("orders.[orderId]", async (user, orderId) => {
  return user.id === (await Order.findOrNew(orderId)).userId; // boolean = private
});

Broadcast.channel("chat.[roomId]", (user, roomId) => {
  return user.canJoin(roomId) ? { id: user.id, name: user.name } : null; // member data = presence
});

Testing with the in-memory recorder:

import { Broadcast } from "@zerotal/broadcasting";

const fake = Broadcast.fake();
await PostController.publish({ http: ctx });
fake.assertBroadcast("PostPublished", "posts", { id: post.id });
Broadcast.resetFake();

Exports

  • BroadcastingEvent / broadcastOnce — base class for broadcastable events.
  • broadcast / PendingBroadcast — fluent dispatch helper (.toOthers(), awaitable).
  • Broadcast — facade (send, to, getMembers, channel, on/private/presence, fake/resetFake).
  • Channel helpers: channel, privateChannel, presenceChannel, isPrivateChannel.
  • BroadcastManager — core manager; TypedBroadcastManager for compile-time-checked channel maps.
  • PusherCompatManager — Pusher/Reverb-compatible protocol manager.
  • RedisBroadcastDriver — Redis Pub/Sub fan-out for multi-instance deployments.
  • broadcastsModelEvents — wire a model's created/updated/deleted to broadcasts.
  • AnonymousBroadcast — inline broadcasts without an event class.
  • ChannelRegistry / channelRegistry / compileChannelPattern — channel auth rule registry.
  • BroadcastFake — test double behind Broadcast.fake().
  • BroadcastProvider — service provider.
  • BroadcastConfig — config factory.
  • Types: PresenceMember, PresenceAuthFn, BroadcastChannelMap, ChannelParams, EventsOf, PayloadOf, TypedBroadcastEvent, BroadcastEvent, WsConnectionData, ChannelAuthFn, RecordedBroadcast, and more.
  • Typed error vocabulary re-exported from ./errors.

Documentation