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.

20 lines (19 loc) 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getMethodTags = exports.addMethodTag = exports.getMethodLabels = exports.addMethodLabel = exports.getMethodMeta = exports.addMethodMeta = void 0; const basic_1 = require("../utils/basic"); const addMethodMeta = (key, mapFn) => (target, propertyKey) => { const metadata = Reflect.getMetadata(key, target.constructor, propertyKey); Reflect.defineMetadata(key, mapFn(metadata), target.constructor, propertyKey); }; exports.addMethodMeta = addMethodMeta; const getMethodMeta = (key, target, propertyKey) => Reflect.getMetadata(key, (0, basic_1.resolveConstructor)(target), propertyKey); exports.getMethodMeta = getMethodMeta; const addMethodLabel = (key, label) => (0, exports.addMethodMeta)('label', (prev = new Map()) => prev.set(key, label)); exports.addMethodLabel = addMethodLabel; const getMethodLabels = (target, propertyKey) => (0, exports.getMethodMeta)('label', target, propertyKey) ?? new Map(); exports.getMethodLabels = getMethodLabels; const addMethodTag = (tag) => (0, exports.addMethodMeta)('tag', (prev = new Set()) => prev.add(tag)); exports.addMethodTag = addMethodTag; const getMethodTags = (target, propertyKey) => (0, exports.getMethodMeta)('tag', target, propertyKey) ?? new Set(); exports.getMethodTags = getMethodTags;