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

quicklime

v1.2.0

Published

A bare bones event dispatcher.

Readme

Quicklime

A bare bones event dispatcher.

Installation

npm install quicklime

Usage

Start by creating an instance of the Quicklime class:

const myEvent = new Quicklime();

If you desire to pass any sort of data, in TypeScript you can pass a type:

const myEvent = new Quicklime<string>();

Adding Callbacks

Callbacks are called each time the event is dispatched. Anonymous functions work great with the on method:

import { Quicklime } from "quicklime";

myEvent.on(() => console.log("myEvent was dispatched!"));

Enjoy the OOP goodness by chaining methods:

myEvent
  .on(() => console.log("callback 1"))
  .on(() => console.log("callback 2"))
  .on(() => console.log("callback 3"))
  .on(() => console.log("callback 4"));

However, if you would like your callback to only be called once, use the once method:

myEvent.once(() => console.log("myEvent was dispatched once!"));

Accessing Event Data

myEvent.on((event) => {
  console.log(`And the event said, "${event.data}"`);
});

You also have access to the data from the last dispatch:

myEvent.on((event) => {
  console.log(`Remember when I was like, "${event.last}"`);
});

By default, the last data is null until the first dispatch happens. If you desire, you can pass an initial value for last so that it is never null. Note that due to limitations on how TypeScript manages types in classes, the type of last will still be Type | null even if you pass an initial value for it:

const myEventWithoutInitial = new Quicklime<string>();
// this'll be null
myEventWithoutInitial.on((event) => console.log(event.last)).dispatch();

// note that you don't have to pass a Type anymore since it's inferred
const myEventWithInitial = new Quicklime("initial value");
// this'll be "initial value"
myEventWithInitial.on((event) => console.log(event.last)).dispatch();

Stopping Propagation

myEvent
  .on(() => console.log("callback 1")) // this will logged
  .on(() => console.log("callback 2")) // this too
  .on((event) => event.stopPropagation()) // nothing here
  .on(() => console.log("callback 3")) // this is never reached
  .on(() => console.log("callback 4")); // nor is this

Dispatching the Event

The event can be dispatched with whatever data you want:

myEvent.dispatch("My name is Quicklime");

Removing Callbacks

If you would like to remove a callback, make sure you save a reference to it before using the on method so that you can later use the off method:

function myCallback() {
  console.log("don't forget about me :)");
}

myEvent.on(myCallback);
myEvent.off(myCallback);

Or go nuclear and remove all callbacks:

myEvent.clear();

Awaiting the Next Event

There is an in-built way to create a promise that waits for the next call:

const event = await myEvent.next();
console.log(`Then I replied, "${event.data}"`);

Accessing All Callbacks

Note that this is a JavaScript Set:

myEvent.callbacks.forEach((callback) => console.log(callback));

Behavior

Errors don't stop all callbacks from being called and are logged properly to the console with the correct stack trace:

myEvent
  .on(() => console.log("callback 1")) // this will be logged
  .on(() => console.log("callback 2")) // so will this
  .on(() => {
    // this error will happen between callbacks 2 and 3
    throw new Error("He's behind me, isn't he?");
  })
  .on(() => console.log("callback 3")) // this is logged nevertheless
  .on(() => console.log("callback 4")); // this too

All calls are asynchronous so no callback can delay another:

myEvent
  .on(async () => {
    const response = await fetch("https://some-really.com/big-file");
    const data = await response.arrayBuffer();
    console.log(data);
  }) // this will take a while to run
  .on(() => console.log("I am fast")); // so this will end up logging first

Stop propagation only works if you are quick enough to call it before Quicklime is done calling all callbacks. In other words, if you are asynchronous, you can't stop propagation:

myEvent
  .on(async (event) => {
    const response = await fetch("https://some-really.com/big-file");
    await response.arrayBuffer();

    event.stopPropagation(); // useless call
  })
  .on(() => console.log("I am fast")); // this will log