All files / common/utils merge-with-values.util.ts

87.5% Statements 7/8
100% Branches 0/0
66.67% Functions 2/3
87.5% Lines 7/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20        1x     2x 2x         2x 2x 2x 2x      
export interface Constructor<T> {
  new (...args: any[]): T;
}
 
export const MergeWithValues = <T extends Constructor<{}>>(data: {
  [param: string]: any;
}) => {
  return (Metatype: T): any => {
    const Type = class extends Metatype {
      constructor(...args) {
        super(...args);
      }
    };
    const token = Metatype.name + JSON.stringify(data);
    Object.defineProperty(Type, 'name', { value: token });
    Object.assign(Type.prototype, data);
    return Type;
  };
};