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

axl-emitter

v1.0.1

Published

Async event emitter with priority queues, once-listeners, and a mutable mid-flight queue.

Readme

axl-emitter

Async event emitter with priority queues and a mutable mid-flight listener list.

  • Listeners run sequentially and are awaited — each handler finishes before the next starts.
  • Numeric priority controls order (higher = first). Default is 0.
  • once listeners auto-remove after the first invocation.
  • Any callback can mutate the queue while it's running: add listeners, remove them, or call offAll() to abort remaining callbacks.
  • Ships as both a class (AxlEmitter) and a standalone utility function (processListeners).
  • Dual package: CJS + ESM, full TypeScript types.
  • Zero dependencies, lightweight.

Install

npm install axl-emitter

Usage

Extend the class

import { AxlEmitter } from 'axl-emitter';

class Dog extends AxlEmitter {
  bark() {
    return this.emit('bark', '🐕 woof!');
  }
}

const dog = new Dog();

dog.on('bark', (sound) => console.log('neighbor heard:', sound), 10);
dog.on('bark', () => console.log('whole street heard it'), 0);

await dog.bark();

Abort mid-flight

// priority 20 runs first — if owner is notified, no need to wake the neighbors
dog.on('bark', async (sound) => {
  await notifyOwner(sound);
  dog.offAll('bark'); // cancels remaining listeners for this emission
}, 20);

await dog.bark();
// notifyOwner runs, then the queue is cleared — neighbors stay asleep

once — fire and forget

dog.once('bark', () => console.log('first bark ever 🎉'));

await dog.bark(); // prints the message
await dog.bark(); // nothing

Remove listeners

const handler = (sound: string) => console.log(sound);
dog.on('bark', handler);

dog.off('bark', handler);  // remove one
dog.offAll('bark');        // remove all

Listener descriptor object

dog.on('bark', {
  callback: async (sound) => save(sound),
  priority: 50,
  once: true,
});

Standalone utility

Manage your own arrays without the class:

import { processListeners, PriorityListener } from 'axl-emitter';

const queue: PriorityListener<[string]>[] = [
  { callback: (msg) => console.log('B', msg), priority:  0 },
  { callback: (msg) => console.log('A', msg), priority: 10 },
];

await processListeners(queue, 'hello');
// A hello
// B hello

API

AxlEmitter

| Method | Description | |---|---| | on(event, listener, priority?) | Register a persistent listener. | | once(event, listener, priority?) | Register a one-shot listener. | | off(event, listener) | Remove a specific listener (matched by callback reference). | | offAll(event) | Remove all listeners for an event. Also aborts the current emission. | | emit(event, ...args) | Fire all listeners; returns Promise<void>. |

listener can be a plain function or a PriorityListener descriptor:

type PriorityListener<T extends any[]> = {
  callback: (...args: T) => Promise<void> | void;
  priority: number;
  once?: boolean;
};

processListeners(listeners, ...args)

Standalone async runner. Sorts listeners in place and processes them sequentially.


Priority rules

  • Higher priority number = runs first.
  • Ties are broken by insertion order.
  • Default priority is 0.

License

MIT