All files / array/src includesAll.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 4/4
100% Lines 4/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                            6x 1x 6x 7x    
/**
 *
 * @example
 * Check if an {@link Array} contains `2` and `3`
 * ```ts
 * const includes2And3 = includesAll([2, 3]);
 * const result = includes2And3([1, 2, 3]);
 * console.log(result); // true
 * ```
 *
 * @typeParam T - the {@link Array} element type
 * @param shouldIncludeValues
 * @returns
 */
export const includesAll =
  <T>(shouldIncludeValues: T[]) =>
  (array: T[]): boolean => {
    return shouldIncludeValues.every((value) => array.includes(value));
  };