0.1.0 • Published 8 years ago
anakin v0.1.0
Quick start
//module/to/get/ module.js
module.exports = `I'm here`;
//app.js
let anakin = require('anakin')({
base: __dirname
});
anakin.map({
something: 'module/to/get/module.js'
});
let something = anakin.get('something');
console.info(something); //I'm here`
API
anakin
: (configuration: Object): Object
This function it useful to configurate how to anakin should to work. It returns an Anakin Object, useful to manage application's dependencies.
let anakinObject = require('anakin')({ base: { String } // [REQUIRED] This attribute shows to anakin where is the bootstrap file. It receives only path as String. Recommended to use the __dirname value. singleton: { Boolean } // When it is truthy, Anakin will keep the dependencies on memory. Otherwise, the dependencies will just be a require cache. });
Anakin Object
map
(mapperObj: Object): void
This method maps all dependencies. The dependecy path does not need has a file extension (e.g .js or .json) because this method uses the
require
method internally.anakin.map({ dependencyName: 'module/to/get/module.js' });
get
(module: String): any
This method get a dependency was set in mapper object.
anakin.get('someDependency');
Pull requests are very welcome!