@blynx/inject
Version:
Dependency injector for javascript
26 lines (25 loc) • 625 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
/**
* js-injectable helper
*
* @export
* @class Injector
*/
class Injector {
/**
* Instantiate a class decorated with Injectable
*
* @static
* @template T Type of class
* @param {{new(...args: any[]): T}} newType The class to instantiate
* @param {...any[]} args Arguments, use for excluded injectables
* @returns {T} New instance of T
*
* @memberOf Injector
*/
static inject(newType, ...args) {
var result = new newType(...args);
return result;
}
}
exports.Injector = Injector;