All files / app/util mixin.ts

0% Statements 0/4
100% Branches 0/0
0% Functions 0/3
0% Lines 0/4

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                                           
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
 * Creates a mixin class from the given base classes.
 * @param derived - The object to apply the mixin to
 * @param bases    - An array of classes which should be mixed
 */
export const applyMixin = (derived: any, bases: any[]): void => {
  bases.forEach((base) => {
    Object.getOwnPropertyNames(base.prototype).forEach((name) => {
      Object.defineProperty(
          derived.prototype,
          name,
          Object.getOwnPropertyDescriptor(
              base.prototype,
              name,
          ) as PropertyDescriptor,
      );
    });
  });
};