Function aperture

  • Returns an array of arrays of length size with consecutive elements from the original array. Returns an empty array if size is shorter than the array or is not an integer.

    Example

    import * as A from "flurp/array";

    const makeTriples = A.aperture(3);
    makeTriples([2, 4, 6, 8, 10, 12, 14]);
    // [
    // [2, 4, 6],
    // [4, 6, 8],
    // [6, 8, 10],
    // [8, 10, 12],
    // [10, 12, 14],
    // ]

    Type Parameters

    • T

    Parameters

    • size: number

    Returns ((arr: readonly T[]) => T[][])

      • (arr: readonly T[]): T[][]
      • Parameters

        • arr: readonly T[]

        Returns T[][]