@blynx/inject
Version:
Dependency injector for javascript
24 lines (23 loc) • 540 B
JavaScript
/**
* js-injectable helper
*
* @export
* @class Injector
*/
export 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;
}
}