Function arrTableAssertRowsSameLength

  • Asserts that all rows in a 2D array have the same length.

    Type Parameters

    • T

    Parameters

    • rows: T[][]

      The 2D array to check.

    • Optional headers: string[]

      Optional. An array of headers. If provided, each row must have the same length as this array.

    Returns void

    Throws

    If any row in the array has a different length than the others.

    Typeparam

    T - The type of elements in the rows.

    Example

     const rows = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
    ];
    arrTableAssertRowsSameLength(rows);
    //=> undefined
    const rowsWithDifferentLength = [
    [1, 2, 3],
    [4, 5],
    [7, 8, 9],
    ];
    arrTableAssertRowsSameLength(rowsWithDifferentLength);
    //=> Error: Expected 3 columns, got 2

Generated using TypeDoc