UNPKG

ts-ioc-container

Version:

Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.

19 lines (18 loc) 642 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProxyInjector = void 0; const IInjector_1 = require("./IInjector"); class ProxyInjector extends IInjector_1.Injector { createInstance(scope, Target, { args = [] } = {}) { const proxy = new Proxy({}, { get(target, prop) { if (prop === 'args') { return args; } return prop.toString().search(/alias/gi) >= 0 ? scope.resolveByAlias(prop) : scope.resolve(prop); }, }); return new Target(proxy); } } exports.ProxyInjector = ProxyInjector;