0.1.3 • Published 9 years ago

inverter-ioc v0.1.3

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
9 years ago

inverter-ioc

Just a fast, tiny and useful IoC container made in Javascript

NPM Version NPM Downloads Linux Build Coverage

Installation

$ npm install inverter-ioc

Quick Start

// Importing the module.
let inverter = import('inverter-ioc');

// Registering the current instance for future use.
inverter.register("registerName", YourClassName);

// Calling a previously created instance.
let resolvedInstance = inverter.resolve("registerName", YourClassName);

Real World Example

// Registering Constants
inverter.register('Constants', function() {
  this.pi = 3.14159;
  return this;
});

// Registering the circle class, using a previously registred function
inverter.register('Circle', function(Constants) {
    this.area = function(radius) {
        return Constants.pi * radius * radius;
    };
    this.getPi = function () {
      return Constants.pi;
    }
    return this;
});

// Resolving the cicle instance
var circle = inverter.resolve('Circle');

// Using the instance
console.log(circle.area(2));
console.log(circle.getPi());

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

To analyze the code coverage status, install all dependencies and run npm run coverage:

$ npm install
$ npm run coverage

Features

  • Upcoming

License

GNU GENERAL PUBLIC LICENSE

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago