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

wardboss

v1.3.0

Published

Dependency injection module. It decides who gets what when they ask for it.

Downloads

9

Readme

wardboss

wardboss decides who gets what when they ask for it. In other words, it does basic dependency injection and currying.

wardboss has constituents and functions. When it calls those functions, different parameters are provided to those functions depending on the constituent for which it is being called.

So, if you call a function named showJobs for the constituent bigjoerusty, it will be passed the param ['committeeman']. However, if you call showJobs for the constituent vrdolyak, wardboss passes the params ['sanitation chief'], ['zoning permits'].

Let's say you have a function that takes three params, like so:

function showJobs(jobs, owedfavors, done) {
  console.log(jobs, owedfavors);
  setTimeout(done, 0);
}

You create a wardboss.

var boss = wardboss.createBoss();

After that, you can register functions with wardboss, giving providers for each constituent. A provider takes a callback, to which it passes an array of (all or some of) the params that the function should get.

boss.addFn({
  fn: showJobs,
  providers: {
    bigjoerusty: function provideShowJobsArgs(context, done) {
      setTimeout(function callDone() {
        done(null, [['committeeman']]);
      },
      0);
    },
    vrdolyak: function provideShowJobsArgs(context, done) {
      setTimeout(function callDone() {
        done(null, [['sanitation chief'], ['zoning permits']]);
      },
      0);
    }
  }
}

Then, you call the function like so. You can pass along any params that are not provided by the providers.

boss.$.vrdolyak.showJobs({
  context: {
    discussionLocation: 'cityHall'
  },
  params: [
    function doneShowingJobs(error, result) {
      console.log('The jobs and favors will have been logged.');
    }
  ]
});

boss.$.bigjoerusty.showJobs({
  context: {
    discussionLocation: 'alley'
  },
  params: [
    ['look the other way'], 
    function doneShowingJobs(error, result) {
      console.log('The jobs and favors will have been logged.');
    }
  ]
});

Installation

npm install wardboss

Specification

createBoss =>

  • Returns a boss object with the following methods and properties:
    • addConstituent
    • addFn
    • fns, an object with function names as the keys and functions as the values
    • $, an object that has constituent names as keys and constituent objects as values.
      • Each constituent has:
        • providers, a dictionary of function name keys and provider function values.

boss.addConstituent(constituentName) =>

  • Adds a constituent to boss.$ using constituentName as the key.

boss.addFn(opts)

  • Where:
    • opts is an object containing:
      • fn, a function
      • providers, an object in which:
        • The keys correspond to constituent names
        • The values are functions that:
          • Take a context and a callback, done.
          • Calls it with error, params, where:
            • params is an array of arguments to be passed to fn.
  • =>
    • Adds fn to boss.fns.
    • Adds values of providers to constituent.providers using 'fn' name as key.
    • Adds a method with the name fn.name to each constituent with a value that is:
      • A function that calls a function using a parameters from the appropriate provider.

boss.$.<constituent c>.<function f>({context, params}) =>

  • Gets provider p from c.
  • Calls p with context to get arguments, which it combines with params (params override arguments) and passes to them f.

Tests

Run tests with make test.

License

MIT.