• Render array of objects as formatted table with Unicode borders.

    Algorithm: Calculate max column widths, generate border/data rows, output via console.log. Uses object keys as default headers.

    Column Width: Max of header length and longest data value per column. Data Handling: Missing properties become empty strings. Edge Cases: Empty arrays, no columns, all-null values handled.

    Parameters

    • data: Object[]

      Array of objects to display as table rows

    • Optionaloptions: Object = {}

      Configuration options

    Returns void

    Outputs table directly to console

    Data parameter must be array

    const users = [
    { name: 'John', age: 30, city: 'NYC' },
    { name: 'Jane', age: 25, city: 'LA' }
    ];
    table(users);
    // ┌──────┬─────┬─────┐
    // │ name │ age │ city│
    // ├──────┼─────┼─────┤
    // │ John │ 30 │ NYC │
    // │ Jane │ 25 │ LA │
    // └──────┴─────┴─────┘

    table(users, { headers: ['Name', 'Age', 'Location'] });