# All files / common/decorators/core reflect-metadata.decorator.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 2/2
100% Lines 6/6

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    2x

    2x
    1x
    1x

    1x
    1x

     /**
     * Assigns the metadata to the class/function under specified `key`.
     * This metadata can be reflected using `Reflector` class.
     */
    export const ReflectMetadata = <K = any, V = any>(metadataKey: K, metadataValue: V) => (
      target: object,
      key?,
      descriptor?,
    ) => {
      if (descriptor) {
        Reflect.defineMetadata(metadataKey, metadataValue, descriptor.value);
        return descriptor;
      }
      Reflect.defineMetadata(metadataKey, metadataValue, target);
      return target;
    };