inverter-ioc

0.1.3 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i inverter-ioc

Weekly Downloads

3

Version

0.1.3

License

GPL-3.0

Last publish

Collaborators

  • felipeuntill