All files mergeAll.ts

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

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                                  1x 3x    
/**
 * Merges a list of objects into a single object.
 * @param array the array of objects
 * @signature
 *    R.mergeAll(objects)
 * @example
 *    R.mergeAll([{ a: 1, b: 1 }, { b: 2, c: 3 }, { d: 10 }]) // => { a: 1, b: 2, c: 3, d: 10 }
 * @category Array
 */
export function mergeAll<A>(array: [A]): A;
export function mergeAll<A, B>(array: [A, B]): A & B;
export function mergeAll<A, B, C>(array: [A, B, C]): A & B & C;
export function mergeAll<A, B, C, D>(array: [A, B, C, D]): A & B & C & D;
export function mergeAll<A, B, C, D, E>(
  array: [A, B, C, D, E]
): A & B & C & D & E;
 
export function mergeAll(items: any[]) {
  return items.reduce((acc, x) => ({ ...acc, ...x }), {});
}