Variable AggregatorsConst

Aggregators: Readonly<Record<AggregatorName, AggregatorIf>> = ...

The built-in aggregators by name (AggregatorName) – each one is an AggregatorIf, so merge combines partial results correctly (the average of groups is the average of all rows).

  • sum and avg sum with compensation (Neumaier): 0.1 + 0.2 + 0.3 is 0.6, and splitting the data into groups does not change the result.
  • Numeric aggregators use numbers only (NaN, text, null … are ignored); min/max also valid Dates; count counts rows; countDistinct ignores null/undefined; first/last take the value as it is.

Example

const { sum } = Aggregators;
let state = sum.init();
for (const order of orders) state = sum.add(state, order.total);
sum.result(state); // the same as aggregate(orders, "total", "sum")

Since

1.1.94