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 🙏

© 2025 – Pkg Stats / Ryan Hefner

crummm-emitter-system

v0.1.1

Published

A zero-dependency emitter system with some fancy features under the hood.

Downloads

6

Readme

Crummm Emitter System

A zero-dependency emitter system with some fancy features under the hood.

Just tell me how to install it!

$ npm i crummm-emitter-system --save

Great...what's it for?

The original intent of this system was to decouple components, libraries, services, etc by allowing them to communicate anonymously. That said, there's countless ways to use emitter systems.

Aren't there like a million emit/on, pub/sub, event/listener systems out there already?

You betcha, and somehow none of them did the trick for me. My dev soul was deeply saddened by the following:

  • wonky implementation
  • unfulfilling feature-sets
  • framework dependencies
  • a lack of TypeScript support
  • developers who fell asleep at the wheel (that's my job!)

Plus, I wanted some advanced features like those referenced later in this documentation.

All that said, will this system work for you? Probably not. Ha! But I kind of like it, so there is that.

Fancy words aside, let's get to the meat and potatoes of this thing.

Basic features

  • emit and listen by type
  • remove listeners by
    • type and callback
    • all by type
    • all
  • do once listeners

Advanced features

  • listen order: this is cool as hell and quite necessary when specific execution order is required
  • requests: anonymously emit a request and listen for a anonymous response...super simple...super cool
  • two different ways to use
    • create any number of system instances: new CrummmEmitterSystemInstance()
    • single system instance via static class methods: CrummmEmitterSystem

Enough talk! What's the implementation look like?!

I hear you! I hate when I have to dig through source code just to get a sense of what the implementation looks like. Fear not, I'll hold your hand through this.

Request example

// listen for requests
CrummmEmitterSystem.onRequest(
  "helloRequest",
  (responseCallback: Function, requestValue: any)=> {
    responseCallback("Hello " + requestValue + "!");
  }
);

// make request for data
CrummmEmitterSystem.emitRequest(
  "helloRequest",
  (response: string)=> {
    console.log(response);
  },
  "Billy"
);

// output: 
// Hello Billy!

Listen order example

const TYPE = "TYPE";
const emitter = new CrummmEmitterSystemInstance();

emitter.onOnce(
  TYPE,
  (payload) => {
    console.log("This should fire 3rd even though it's setup 1st: ", payload.message);
  },
  5 // this param is the listen order!
);

emitter.onOnce(
  TYPE,
  (payload) => {
    console.log("This should fire 1st even though it's setup 2nd: ", payload.message);
  },
  1 // so is this! notice it's a lower number than the previous 'onOnce' listener...so it'll fire before it.
);

emitter.onOnce(
  TYPE,
  (payload) => {
    console.log("This should fire 2nd even though it's setup 3rd: ", payload.message);
  },
  2 // someone has to be in the middle of this sandwich...and since 2 is in-between 1 and 5 it looks like we found our victim.
);

setTimeout(
  () => {
    emitter.emit(TYPE, { message: "Hello listenOrder!" });
  },
  1000
);

// console.log:
// This should fire 1st even though it's setup 2nd:  Hello listenOrder!
// This should fire 2nd even though it's setup 3rd:  Hello listenOrder!
// This should fire 3rd even though it's setup 1st:  Hello listenOrder!

How to go forward...

TODO - npm

Install / setup / npm

$ npm -i

Run

$ npm start

Test

$ npm test

Examples

Check out the 'examples' directory for different implementations and usages.

Errors

What'd you do wrong now?! Hey, don't beat yourself up, I've probably done the same thing already. Check out my mistakes and (hopefully) solutions below!

  • tsc command not found
    • when: occurs after attempting to run command $ npm start
    • mistake: something got jacked up...so I'm not beating myself up for this one
    • solution: $ npm install typescript -g

If using an IntelliJ product

  • mark the following directories as excluded
    • dist
    • examples

In conclusion

Did I miss something? Let me know if I did...and feel free to checkout my dev blog below:

Crummm Dev