Node · bundled + unbundled browser · synchronous

Fast events.
No ceremony.

One small publish/subscribe class for Node.js, bundled browser applications, and unbundled native ESM—with predictable wildcard ordering, fluent methods, and no required build step.

npm install event-pubsub

Release status: 6.1.1 is the current npm and GitHub release.

131unique behavior checks
typed emit · one handler
100%coverage gates
1runtime dependency

The small surface

Learn five methods, ship the event flow.

Registration and dispatch stay direct. The deeper documentation is split into focused pages so you can get an answer without crossing a wall of prose.

on and once

Register persistent or one-shot subscribers. One-shot records are removed before invocation, including reentrant emits.

Read the API →

emit

Run wildcard subscribers first, then typed subscribers, synchronously and in registration order.

See patterns →

off and reset

Remove one function, one topic, wildcard subscribers, or the complete registry while keeping fluent chaining.

Understand lifecycle →

Without a bundler

The 6.1.1 source runs directly as native browser ESM. Put the map before the first module script and serve the installed files over HTTP(S).

<script type="importmap">
{"imports":{"event-pubsub":"./node_modules/event-pubsub/index.js","strong-type":"./node_modules/strong-type/index.js"}}
</script>
<script type="module">
import EventPubSub from 'event-pubsub';

const events = new EventPubSub();

events.on('ready', (payload) => {
    console.log(payload);
});

events.emit('ready', { fast: true });
</script>

If the app uses a strict CSP, authorize the inline import-map and module scripts with an allowed nonce or hash.

Quality is inspectable

Tests, coverage, and speed are public artifacts.

The same shared suite runs in Node and real Chrome. Independent coverage reports, normalized results, package smoke tests, and execution-latency charts ship with the Pages deployment.