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

@billdaddy/eventkit

v0.1.0

Published

Zero-dependency typed async EventEmitter: compile-time event types, async dispatch (await all handlers), Promise-based once(), event history/replay, wildcard listeners. Port of Java Guava EventBus / Python blinker.

Readme

eventkit

All Contributors

Zero-dependency typed async EventEmitter. Compile-time event type safety, async dispatch (await all handlers in order), Promise-based once, event history + late-subscriber replay, wildcard listeners. Port of Java Guava EventBus / Python blinker.

npm License: MIT

Install

npm install @billdaddy/eventkit

Why

eventemitter3 (17M/week) and mitt (4M/week) are great but they lack:

  • emitAsync() — await all handlers in registration order
  • onceAsync() — Promise that resolves on next emit (AbortSignal support)
  • Event history with late-subscriber replay (onWithReplay)
  • Wildcard onAny listener

Quick start

import { createEmitter } from "@billdaddy/eventkit";

// Declare your event map — names → argument tuples
type AppEvents = {
  login:   [user: { id: number; name: string }];
  logout:  [userId: number];
  error:   [err: Error];
  ready:   [];
};

const bus = createEmitter<AppEvents>();

// TypeScript knows `name` is a string here
bus.on("login", (user) => console.log(`Welcome ${user.name}`));

// Async handler — properly awaited by emitAsync()
bus.on("login", async (user) => {
  await saveToDatabase(user);
});

// Emit (sync — async handlers start but are NOT awaited)
bus.emit("login", { id: 1, name: "Alice" });

// Emit async — awaits all handlers in registration order
await bus.emitAsync("login", { id: 1, name: "Alice" });

Promise-based once

// Wait for the next "ready" event
const [] = await bus.onceAsync("ready");

// With AbortSignal (cancel waiting)
const ac = new AbortController();
setTimeout(() => ac.abort(), 5000); // cancel after 5s
try {
  const [user] = await bus.onceAsync("login", ac.signal);
  console.log(`Logged in: ${user.name}`);
} catch {
  console.log("Timed out waiting for login");
}

Event history + late-subscriber replay

const bus = createEmitter<AppEvents>({ history: 10 });

bus.emit("login", { id: 1, name: "Alice" });
bus.emit("login", { id: 2, name: "Bob" });

// Late subscriber gets past events replayed first, then future ones
bus.onWithReplay("login", (user) => console.log(user.name));
// prints: Alice, Bob  (replayed)

bus.emit("login", { id: 3, name: "Carol" });
// prints: Carol  (new event)

// Inspect history
bus.getHistory("login");  // [[{id:1,name:"Alice"}], [{id:2,...}]]
bus.clearHistory("login");

Wildcard listener

bus.onAny((eventName, ...args) => {
  console.log(`[${String(eventName)}]`, args);
});

bus.emit("login", { id: 1, name: "Alice" });
// → [login] [{id:1,name:"Alice"}]

Unsubscribe patterns

// Pattern 1: unsubscribe function
const unsub = bus.on("login", handler);
unsub();  // removes this listener

// Pattern 2: off()
bus.off("login", handler);

// Pattern 3: remove all for one event
bus.offAll("login");

// Pattern 4: remove everything
bus.offAll();

Async error handling

bus.on("login", async () => { throw new Error("DB down"); });
bus.on("login", async () => { /* this still runs */ });

try {
  await bus.emitAsync("login", user);
} catch (e) {
  // AggregateError — all handler errors collected
  if (e instanceof AggregateError) {
    console.log(e.errors); // [Error("DB down")]
  }
}

API

new TypedEmitter<Events>(options?: { history?: number; maxListeners?: number })
createEmitter<Events>(options?)  // shorthand

// Subscribe
.on(event, listener): () => void          // returns unsub fn
.once(event, listener): () => void
.onWithReplay(event, listener): () => void // replays history first
.onAny(listener): () => void              // wildcard — all events
.off(event, listener): this
.offAll(event?): this

// Emit
.emit(event, ...args): boolean            // sync; true if any listener
.emitAsync(event, ...args): Promise<void> // awaits handlers sequentially

// Promise-based
.onceAsync(event, signal?): Promise<args tuple>

// History
.getHistory(event): args[][]
.clearHistory(event?): this

// Introspection
.listenerCount(event): number
.listeners(event): Listener[]
.eventNames(): (keyof Events)[]
.setMaxListeners(n): this
.getMaxListeners(): number

Comparison

| | eventkit | eventemitter3 | mitt | |---|---|---|---| | TypeScript types | ✅ generics | ✅ | ✅ | | emitAsync (await handlers) | ✅ | ❌ | ❌ | | onceAsync (Promise) | ✅ | ❌ | ❌ | | Event history + replay | ✅ | ❌ | ❌ | | Wildcard onAny | ✅ | ❌ | ✅ | | AbortSignal support | ✅ | ❌ | ❌ | | Zero dependencies | ✅ | ✅ | ✅ |

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

MIT © trananhtung