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

je-di

v1.3.0

Published

Just Enough dependency injection

Readme

Just Enough Dependency Injection

Travis CI

This is yet another dependency injection module, based on ideas of Angular di.

Usage

import jedi from 'je-di';

const jediModule = jedi
  .module()
  // registers an injectable directly
  .register('something', 'Hello')

  // registers what's returned by the given function as an injectable
  .factory('somethingElse', function (something) {

    return `${something} world !`;
  })

  // Registers a newable as injectable (calls new on it before register)
  .service('someService', function (somethingElse) {
    this.greetings = function () {
      console.log(somethingElse);
    };
  })
  .run(function (someService) {
    someService.greetings();
  });

  jedi.bootstrap(jediModule);

  module.exports = jediModule;

The code above will result in the following console statement:

Hello world !

Module dependency

You can include all of a module's injectables into another module by giving a module array in .module() :

const module1 = jedi
  .module()
  .register('foo', 'bla');


const module2 = jedi
  .module([module1])
  .run(function (foo) {
    // here foo === 'bla'
  });

api

jedi.module() method

Creates a new module and returns it.

Arguments

  • dependencies (Optional array): an array of modules that will be loaded. All the module's dependencies' injectables will be available in the module, and their run methods will be run in order before the module's own run method when bootstrapped.

module.register(name, injectable) method

Registers a given injectable under the given name, to be injected.

For example:

// index.js

import jedi from 'je-di';

const jediModule = jedi
  .module()
  .register('foo', 'bar')
  .run(function (foo) {
    console.log(foo);
  });

jedi.bootstrap(jediModule);

Result:

$ node index.js
bar

module.factory(name, injectable) method

Registers a given factory under the given name. When the name is given as a dependency, the result of the factory is inserted in the module's injectables and returned in the injected object.

For example:

// index.js

import jedi from 'je-di';

const jediModule = jedi
  .module()
  .factory('foo', function () {
    return 'bar';
  })
  .run(function (foo) {
    console.log(foo);
  });

jedi.bootstrap(jediModule);

Result:

$ node index.js
bar

module.service(name, injectable) method

Registers a given service as a newable under the given name. When the name is given as a dependency, the service is called with new, and the result is inserted in the module's injectables and returned in the injected object.

For example:

// index.js

import jedi from 'je-di';

const jediModule = jedi
  .module()
  .service('foo', function () {
    this.baz = 'bar';
  })
  .run(function (foo) {
    console.log(foo.baz);
  });

jedi.bootstrap(jediModule);

Result:

$ node index.js
bar

module.run() method

Registers a method to be called when the module is bootstrapped. The method's named parameters are injected with the module's or its dependency's injectables.

For example:

// index.js

import jedi from 'je-di';

const jediModule = jedi
  .module()
  .service('foo', function () {
    this.baz = 'bar';
  })
  .run(function (foo) {
    console.log(foo.baz);
  });

jedi.bootstrap(jediModule);

Result:

$ node index.js
bar

module.resolve() method

When given an array of names, this method returns an array of injectables from the module or its dependencies.

For example:

// index.js

import jedi from 'je-di';

const jediModule = jedi
  .module()
  .service('foo', function () {
    this.baz = 'bar';
  });

console.log(jediModule.resolve(['foo']));

Result:

$ node index.js
['bar']

module.get() method

When given a single name, this method returns the associated injectable from the module or its dependencies.

For example:

// index.js

import jedi from 'je-di';

const jediModule = jedi
  .module()
  .service('foo', function () {
    this.baz = 'bar';
  });

console.log(jediModule.get(['foo']));

Result:

$ node index.js
bar

Contributing:

All contribution, feedback, issues and PR welcome. Just try to keep the code clean, and add tests.

License

MIT license