0.1.3 • Published 7 years ago

inverter-ioc v0.1.3

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
7 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

7 years ago

0.1.2

7 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago