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

@allnulled/triggers-class

v1.0.0

Published

Register and emit async triggers using asterisks, names, priority and parameters through a less than 100 lines script.

Readme

triggers-class

Register and emit async triggers using asterisks, names, priority and parameters. Less than 100 lines script.

Installation

npm i -s @allnulled/triggers-class

Import

In node.js:

require("@allnulled/triggers-class");

In html:

<script src="node_modules/@allnulled/triggers-class/triggers-class.js"></script>

Then you can use window.TriggersClass or global.TriggersClass.

API

These are the signatures of the methods:

TriggersClass.globMatch(patterns, list);
const triggersClass = new TriggersClass();
triggersClass.all = {};
triggersClass.register(triggerNamePattern, triggerIdentifier, triggerCallback, triggerConfigurations = {});
await triggersClass.emit(triggerName, parameters = {});
triggersClass.unregister(triggerIdentifier);

The globMatch static method accepts a patterns list, and a texts list. It will return the texts that match at least one pattern.

The register method requires name:string, identifier:string and callback:function. Optionally, configurations:object.

  • name is the name of the event. This one accepts * as any character/s, like glob patterns.
  • identifier is the name of this registration.
  • callback is the function triggered.
  • configurations is an object. It can have priority as a number. The higher, the sooner. Passed to the callback too.

The emit method requires name:string with the name of the event (no * accepted here). Optionally, parameters:object, passed to the callback too.

The unregister method requires only identifier:string, the same used on register call previously.

Example

This is the current test of the library.

console.log(TriggersClass.globMatch([
    "crud.insert.*.users",
    "crud.*.many.users"
], [
    "crud.select.one.users",
    "crud.select.many.users",
    "crud.insert.one.users",
    "crud.insert.many.users",
    "crud.update.one.users",
    "crud.update.many.users",
    "crud.delete.one.users",
    "crud.delete.many.users",
]));
const triggers = new TriggersClass();
let counter = 0;
triggers.register("crud.insert.one.tabla1", "temp1", function () {
    console.log("triggering temp1");
    counter -= 2;
    return 100;
}, {
    priority: 20
});
triggers.register("crud.insert.one.tabla1", "temp2", function () {
    console.log("triggering temp2");
    counter *= 10;
    return 10;
}, {
    priority: 10
});
triggers.register("crud.insert.one.tabla1", "temp3", function () {
    console.log("triggering temp3");
    counter += 5;
    return 1;
}, {
    priority: 30
});
const output = await triggers.emit("crud.insert.one.tabla1", { in: 500 });
const outputSum = output.reduce((o,i) => {
    o += i;
    return o;
}, 0);
setTimeout(() => {
    console.log(counter);
    console.log(outputSum);
    if(counter !== 30) {
        throw new Error("Triggers order is not as expected");
    }
    if(outputSum !== 111) {
        throw new Error("Emit is not working as expected");
    }
}, 1000);