All files / array/operator interleave.ts

100% Statements 10/10
100% Branches 2/2
100% Functions 2/2
100% Lines 7/7

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 134x 7x 1x   2x 2x 3x   2x        
export const interleave = <E>(arr1: E[]) => (arr2: E[]) => {
  if (arr1.length !== arr2.length) {
    throw new Error('Input arrays must have equal lengths');
  }
  const result: E[] = [];
  for (let i = 0; i < arr1.length; i++) {
    result.push(arr1[i], arr2[i]);
  }
  return result;
 
};