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

tacklebox-js

v0.1.3

Published

A small library for generating api hooks for your javascript app.

Downloads

6

Readme

TackleBox

TackleBox is a small JavaScript library for registering and calling hooks. You can use these hooks to create an API for your library or app.

Setup

  1. Import TackleBox into your project:
  • <script src="node_modules/tacklebox/dist/tacklebox.js"></script>
  1. Then Initialize the TackleBox Hooks object:
  • <script>Hooks = new TackleBox.Hooks();</script>

Usage

With TackleBox Hooks there are two main methods:

  1. Hooks.register(name:string, args:Array, callback:Function)
  • name - The name of the hook you would like to hook into.
  • callback - The callback function for operating on hook data.
  • args - All of the arguments exposed by the hook.
  1. Hooks.call(name:string, args:Array, processor?:Function)
  • name - The name you would like to give this hook.
  • processor - An optional callback function for processing the data returned from registered callbacks.
  • args - An Array of data values from the registered callbacks.

Hooks.call() && Hooks.callOnce()


Use this method to create a hook. When you create a hook you are exposing a place within your codebase to enable other scripts to either read data from the hook or modify data within your codebase.

Here's an example of what this might look like in your project. You can also find the source code here:

var Calculator = function() {

  function Calculator(a, b) {
    this.a = a;
    this.b = b;
  }

  Calculator.prototype.add = function() {

    // This hook will only be called a single time
    var beforeAdd = Hooks.callOnce('beforeAdd', [this.a, this.b], (value) => {
      console.log("beforeAdd = "+value);
      return value || 0;
    });

    var added = beforeAdd + this.a + this.b;
    console.log("a + b + beforeAdd = "+added+" = x");

    // This hook can be called an unlimited number of times
    var afterAdd = Hooks.call('afterAdd', [added], (values) => {

      // Values is an accumulated array of values returned by registered hooks.
      // Here we are iterating over all of the values in the array and adding
      // them to a running total.
      var addAdditional = values.reduce((total, num, index) => {
        console.log("addAdditional"+index+" = "+num);
        return (total + num);
      },0);

      console.log("additionalTotal = "+addAdditional);

      return added + addAdditional;

    });

    return afterAdd;

  }

  return Calculator;
}();

Hook.register()


Use this method for hooking into exposed hooks. Whatever your hook returns will be passed to the call method's processing callback function.

Hooks.register('beforeAdd',(args) => {
  return 1;
});

Hooks.register('afterAdd',(args) => {
  return 3;
});

Hooks.register('afterAdd',(args) => {
  return 5;
});

var a = 2;
var b = 4;

var myCalculator = new Calculator(a,b);
console.log("x + additionalTotal = "+myCalculator.add());

After calling these hooks we should expect the console output of myCalculator.add() to be equal to 15.