Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

group-aggregate

CI

In-memory analytics: groupBy with multi-key aggregations, having filters, and pivot helper.

What & Why

Group rows of data by keys, compute sums/averages/counts per group, filter on aggregates, and pivot tables. Zero dependencies, typed aggregation config, suitable for reports and dashboards.

API

export function groupBy(rows, keys, aggregates?, having?, orderBy?)  GroupResult[]
export function pivot(rows, rowKey, colKey, valueAgg?, valueKey?)  GroupResult[]

Install

npm install @ferrow/group-aggregate

Quick Start

import { groupBy, pivot } from 'group-aggregate';

const sales = [
  { product: 'A', region: 'US', amount: 100 },
  { product: 'A', region: 'EU', amount: 150 },
  { product: 'B', region: 'US', amount: 200 },
];

const totals = groupBy(sales, ['product'], { total: 'sum' }, undefined, (a, b) => b.total - a.total);
// => [ { product: 'B', total: 200 }, { product: 'A', total: 250 } ]

const pivotTable = pivot(sales, 'product', 'region', 'sum', 'amount');
// => [ { product: 'A', US: 100, EU: 150 }, { product: 'B', US: 200 } ]

Limits

  • Aggregations compute only on numeric columns; non-numeric values become undefined.
  • In-memory only; rows larger than available RAM will fail.
  • No query optimization; scans entire dataset once per groupBy call.

Part of the ferrow-toolkit collection · Sponsored by Ferrow

About

In-memory analytics: groupBy with multi-key aggregations, having filters, and pivot helper

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages