All files / array/operator zip3.ts

100% Statements 11/11
100% Branches 4/4
100% Functions 3/3
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 14    6x 9x 3x     2x 2x 3x   2x    
import {Triple} from 'fnxt/fnxt-types';
 
export const zip3 = <T>(a: T[]) => <U>(b: U[]) => <S>(c: S[]): Triple<T, U, S>[] => {
  if (a.length !== b.length || c.length !== a.length) {
    throw Error('arrays differ in length');
  }
 
  const result: Array<Triple<T, U, S>> = [];
  for (let i = 0; i < a.length; i++) {
    result.push([a[i], b[i], c[i]]);
  }
  return result;
};