Function aggregateColumns

  • Aggregates several values in one pass over the rows. The keys of specs name the results; a key is also the default property path.

    Type Parameters

    • T = any

    Parameters

    Returns Record<string, unknown>

    key → result, in the order of specs

    Example

    const totals = aggregateColumns(orders, {
    quantity: "sum",
    total: "sum",
    customer: "countDistinct",
    avgTotal: { aggregator: "avg", value: "total" }
    });
    // { quantity: 549812, total: 27481033.5, customer: 412, avgTotal: 274.81 }

    Since

    1.1.94