All files / set/src addAll.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 4/4
100% Lines 5/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                          9x 2x 9x 11x 9x    
import { SetCompatible } from "./_types";
 
/**
 *
 * @mutation
 *
 * @example
 * addAll([1,2])([]) => [1,2]
 * addAll([1,2])([2,3]) => [1,2,3]
 *
 * @param set
 * @returns
 */
export const addAll =
  <T>(set: Set<T>) =>
  (values: SetCompatible<T>): Set<T> => {
    values.forEach((value) => set.add(value));
    return set;
  };