Code Monkey home page Code Monkey logo

injekt's Introduction

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 [email protected]: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

  • Released under the MIT License (attached).
  • Accompanied by a full integration test suite, via should and vows.
  • DISCLAIMER: This project is still highly experimental - updates may break backwords-compatibility.

injekt's People

Contributors

aeberlin avatar

Watchers

Eric Burin des Roziers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.