All files / src interpolate1.ts

78.57% Statements 11/14
0% Branches 0/2
100% Functions 1/1
75% Lines 9/12

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    22x 78x     78x     78x 78x 27x 27x   78x     78x  
/** @returns interpolated array with `y` elements. */
export const interpolate1 =
  <T, I>(xs: T[], y: I): (T | I)[] => {
    Iif (!Array.isArray(xs)) {
      throw new TypeError(`Expected xs to be an array, got ${xs}.`)
    }
    Iif (xs.length === 0) {
      return []
    }
    const rs: (T | I)[] = [ xs[0] ]
    for (let i = 1; i < xs.length; i++) {
      rs.push(y)
      rs.push(xs[i])
    }
    return rs
  }
 
export default interpolate1