# All files / src/helpers/matchers matchArrayProp.ts

83.33% Statements 5/6
83.33% Branches 5/6
100% Functions 2/2
80% Lines 4/5

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

    7x
    2x

    5x

    9x

     /**
     * Matches whether given array prop contains the given value, or all given values.
     *
     * @param prop - The array prop to match.
     * @param matcher - The value or values to be included in the array.
     * @returns Whether the array prop contains the given value, or all given values.
     */
    export function matchArrayProp(
      prop: Array<string> | undefined,
      matcher: string | Array<string>
    ): boolean {
      if (!prop || matcher.length === 0) {
        return false;
      }

      Iif (typeof matcher === 'string') {
        return prop.includes(matcher);
      }

      return matcher.every((e) => prop.includes(e));
    }