0.1.9 • Published 11 years ago

injekt v0.1.9

Weekly downloads
5
License
-
Repository
github
Last release
11 years ago

INJEKT - Simple Dependency Injection

Dependency Status Code Climate

INJEKT is a tiny, integration-tested dependency injection framework for NodeJS.

Feel free to skip ahead if you know what you're looking for.

Background Philosophy

NOTE: This section is still under construction.

Installation Options

In addition to the options below, you can download either the raw export or package tarball.

Install via npm:

npm install injekt

Clone GIT repository:

git clone git@github.com:arkbot/injekt.git

Syntax: Library Instantiation

General Usage: require('injekt')( default_options [, closure] );

The following examples are all valid. Use them wisely.

Minimal Reference

var injekt = require('injekt')();
  • NOTE: closure defaults to empty { } when default_options are excluded.

Reference via require(...): injekt(...)

var injekt = require('injekt')({
  'context' : {
    'inspect' : require('util').inspect
  },
  'mocks' : { 
    'assert' : require('should')
  }
}, { });

Reference via closure: closure.injekt(...)

var closure = {};

require('injekt')({
  'context' : {
    'inspect' : require('util').inspect
  },
  'mocks' : { 
    'assert' : require('should')
  }
}, closure);

Reference via global: global.injekt(...)

require('injekt')({
  'context' : {
    'inspect' : require('util').inspect
  },
  'mocks' : { 
    'assert' : require('should')
  }
});
  • NOTE: closure defaults to global when excluded.

Syntax: Module Injection

General Usage: injekt( module_path [, options] );

INJEKT gives you two different methods of injecting your dependencies:

  • context: embed directly into the global context of your product module.
  • mock: available as a mock to be retrieved via require(...) inside your product module.
var my_module = injekt('./my_module.js', {
  'context' : { 
    'EventEmitter' : require('events').EventEmitter
  },
  'mocks' : {
    'Foo' : Object.create({ bar: function () { return 'YIPPPEEEE!'; } })
  }
});
  • NOTE: module_path must be relative to the overall working directory.

Current Goals

Future Thoughts

  • Use factories for params parsing / properties building
  • Integrate browser compatability:

Bug Reports + Other Requests

  • Please submit an issue on the GitHub Issue Tracker.

  • Please attach at least one of the following for bug reports:

    • diagnostic procedure
    • sample code
    • assertion tests
  • Please e-mail me before sending a pull request.

Further Notes

0.1.9

11 years ago

0.1.8

11 years ago

0.1.7

11 years ago

0.1.5

11 years ago

0.1.0

12 years ago