Skip to content

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

License

Notifications You must be signed in to change notification settings

felipeuntill/inverter-ioc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inverter-ioc

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

NPM Version NPM Downloads Linux Build Coverage dependencies Status

Installation

$ npm install inverter-ioc

Quick Start

// Importing the module.
let inverter = require('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

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

// 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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published