Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 1x 1x 39x 1x 6x 6x 6x 6x 6x | import "reflect-metadata"; import { InjectablesKeys, TypeKey } from "./constants"; /** * @description Generates a fully qualified reflection metadata key. * @summary Returns the reflection key for injectables by prefixing the provided key with the base reflection key. * @param {string} key The key to be prefixed * @return {string} The fully qualified reflection key * @function getInjectKey * @memberOf module:injectable-decorators */ export const getInjectKey = (key: string) => InjectablesKeys.REFLECT + key; /** * @description Extracts the type name from a decorated property using reflection. * @summary Retrieves the type from a property decorator by accessing TypeScript's reflection metadata. * @param {any} model The target object containing the decorated property * @param {string | symbol} propKey The property key (name or symbol) of the decorated property * @return {string | undefined} The name of the property type, or undefined if it's a Function type * @function getTypeFromDecorator * @memberOf module:injectable-decorators */ export function getTypeFromDecorator( model: any, propKey: string | symbol ): symbol | undefined { const typeDef = Reflect.getMetadata(TypeKey, model, propKey); Iif (typeDef.name === "Function") { return undefined; } const meta = Reflect.getMetadata( getInjectKey(InjectablesKeys.INJECTABLE), typeDef ); Iif (!meta) { return undefined; } return meta.symbol; } |