UNPKG

nestjs-auto-reflect-metadata-emitter

Version:

[![Actions Status](https://github.com/Codibre/nestjs-auto-reflect-metadata-emitter/workflows/build/badge.svg)](https://github.com/Codibre/nestjs-auto-reflect-metadata-emitter/actions) [![Actions Status](https://github.com/Codibre/nestjs-auto-reflect-metad

34 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DEFAULT = void 0; exports.applyPropertyAndMethodsDecorators = applyPropertyAndMethodsDecorators; exports.applyClassDecorators = applyClassDecorators; const get_proper_metadata_target_1 = require("./internal/get-proper-metadata-target"); const meta_info_1 = require("./meta-info"); const decorators_1 = require("./plugin/decorators"); exports.DEFAULT = Symbol('default'); function applyPropertyAndMethodsDecorators(clsOrMeta, propertyAndMethodsDecorators) { const meta = (0, decorators_1.isMetadata)(clsOrMeta) ? clsOrMeta : (0, meta_info_1.getClassMetadata)(clsOrMeta); if (!meta) throw new Error('No class metadata found'); const cls = meta.ctor.cls; const def = propertyAndMethodsDecorators[exports.DEFAULT]; for (const prop of meta?.properties.values()) { const decorators = propertyAndMethodsDecorators[prop.name] ?? def; if (decorators) { Reflect.decorate(decorators, (0, get_proper_metadata_target_1.getProperMetadataTarget)(prop, cls), prop.name); } } for (const prop of meta?.methods.values()) { const decorators = propertyAndMethodsDecorators[prop.name] ?? def; if (decorators) { Reflect.decorate(decorators, (0, get_proper_metadata_target_1.getProperMetadataTarget)(prop, cls), prop.name); } } } function applyClassDecorators(cls, decorators) { Reflect.decorate(decorators, cls); } //# sourceMappingURL=decorator-helpers.js.map