All files / array/operator zip.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 13    5x 8x 1x   3x 3x 8x   3x    
import {Tuple} from 'fnxt/fnxt-types';
 
export const zip = <E>(arr1: E[]) => <F>(arr2: F[]): Array<Tuple<E, F>> => {
  if (arr1.length !== arr2.length) {
    throw new Error('Input arrays must have equal lengths');
  }
  const result: Array<Tuple<E, F>> = [];
  for (let i = 0; i < arr1.length; i++) {
    result.push([arr1[i], arr2[i]]);
  }
  return result;
};