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

simpleplan

v0.1.1

Published

Simple dependency injector for your precious node apps.

Downloads

17

Readme

simpleplan.js

Simple dependency injector for your precious node apps. Build status

Installation

npm install simpleplan --save

Usage:

you write yourself a delicious module

// my-module.js
require('simpleplan')();

var iNeedMongooseHere = function(Mongoose) {
  // Do some dirty things with Mongoose
}.inject();

And then on the main app you go like

// index.js
var simpleplan = require('simpleplan')();
simpleplan.register("Mongoose", "store here any object you would like.");
simpleplan.register("app",      "and it will magically injected to your favorite methods");

var myModule = require('myModule')(); // Mongoose will magically be injected into the function. wow. I know.

That's it.

WAT

By calling the base require of simpleplan, it extends javascript's Function and provides 2 more methods: inject() and use(params).

register(key, value)

simply stores your dependencies in a key-value hash for the default dependencies. It was made for not passing a dependencies hash for every function you want to inject to.

simpleplan.register("a", { thisIs: "Its value" }); // It will be injected to any 'a' parameter
                                                   // unless it is being overriden in the function call.

use(params)

Tells simpleplan you want to inject some dependencies to this function, with the right order.

Parameter names are not strict.

var somefunc = function(a,b,c) {
  console.log("a: " + a + ", b: " + b + ", c: " + c);
}.use("c", "b", "whoIsAwesome");

somefunc({ c: "First", b: "Second", whoIsAwesome: "Gal Schlezinger" }); // "a: First, b: Second, c: Gal Schlezinger"

inject()

Same as use(params) only here you don't need to give in an array of dependency names - it takes them from the method signature.

var somefunc = function(a,b,c) {
  console.log("a: " + a + ", b: " + b + ", c: " + c);
}.inject();

somefunc({ b: "First", c: "Second", a: "Gal Schlezinger" }); // "a: Gal Schlezinger, b: First, c: Second"

Don't touch my Function's prototype!

Well, you can also go like

var simpleplan = require('simpleplan');
var inject   = simpleplan.inject,
    register = simpleplan.register;

register("param", "Hugh Jackman!");

var func = inject(function(param) {
  return "Who's the man? " + param;
});

func("Gal!"); // => "Who's the man? Gal!"
func(); // "Who's the man? Hugh Jackman!"

but as you can see, its not as awesome as extending Function.

CoffeeScript Usage

{ register, inject } = require 'simpleplan'

register "first", "Hello"
register "second", "World"

myFunc = inject (first, second) ->
  "#{first} #{second}!"

myFunc() # => "Hello World!"
myFunc first: "wat" #=> "wat World!"

Changelog

0.1.0

  • Added registry for stop passing the dependencies object to every method.

0.0.2

  • Added CoffeeScript support (inject ->..)

Contributing

  • Fork this repo.
  • Install dependencies. (npm install)
  • Make sure it runs all the tests. (mocha)
  • Branch.
  • Code.
  • Pull Request.
  • $$$.