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

hookrunner25a-pmb

v0.1.1

Published

Rudimentary EventEmitter-style event manager for running serially async handler chains that update a shared state object unless the chain is aborted.

Downloads

9

Readme

hookrunner25a-pmb

Rudimentary EventEmitter-style event manager for running serially async handler chains that update a shared state object unless the chain is aborted.

API

This module exports one function:

makeHookRunner()

Returns a fresh new runHook function that will have this API:

runHook(hookName[, initialState[, prepareIfAny]])

Return a promise for the state object that will resolve once the chain ended. The state will start as

const hookState = { hookName, hookAborted: false, ...initialState };

If there are no hook functions registered for hookName, the chain ends immediately, and the initial state is returned.

Otherwise, the actual chain is determined, starting with prepareIfAny if is truthy, and then all the actual hook functions.

  • The functions in the chain will be await-ed in series, as long as hookAborted stays false-y.
  • They will be called with a single argument, hookState.
  • If their result is truthy, it will be Object.assigned into the hookState, unless it's one of these magic strings:
    • 'ABORT' will instead be treated as { hookAborted: true }.

runHook.add(hookName, hookFunc)

Append hookFunc to the chain for hookName. Throws an error is it's already on that chain. Otherwise, return a success object whose unsubscribe key will hold a function that can be called once to remove hookFunc from the chain.

Usage

:TODO:

Related projects

  • eventemitter2 has way cooler features, but lacks the event state updating magic and I'm not sure if it can run handlers in series.
  • eventemitter3 also is really neat but cannot run handlers in series.
  • hookable isn't clear about the extent of their promises support (as of 2025-05-12 / v5.5.3, the only mention of "promise" is in a migration note) and seems to have no abort feature. Also not clear whether promising hooks can run in series.

Known issues

  • Needs more/better tests and docs.

 

License

ISC