UNPKG

tsunamy

Version:

A new typesript framework

23 lines (22 loc) 803 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); require("reflect-metadata"); var Injector = /** @class */ (function () { function Injector() { this.map = new Map(); } Injector.prototype.resolve = function (target) { var _this = this; var tokens = Reflect.getMetadata('design:paramtypes', target) || []; var injections = tokens.map(function (token) { return _this.resolve(token); }); var classInstance = this.map.get(target); if (classInstance) { return classInstance; } var newInstance = new (target.bind.apply(target, [void 0].concat(injections)))(); this.map.set(target, newInstance); return newInstance; }; return Injector; }()); exports.Injector = Injector;