mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-18 01:37:54 +00:00
Docs: Update benchmark results
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
export const processCSV = async (csvString, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) => {
|
||||
const [{ csvParse }, { rollup, sum, mean }] = await Promise.all([
|
||||
import('https://esm.sh/d3-dsv'),
|
||||
import('https://esm.sh/d3-array')
|
||||
]);
|
||||
|
||||
const getValue = d => +(d[aggregateColumn]) || 0;
|
||||
|
||||
const grouped = rollup(
|
||||
csvParse(csvString).filter(row => row[filterColumn] == filterValue),
|
||||
group => operation === 'count'
|
||||
? group.length
|
||||
: (operation === 'sum' ? sum : mean)(group, getValue),
|
||||
row => row[groupBy]
|
||||
);
|
||||
|
||||
return Array.from(grouped, ([key, result]) => ({ [groupBy]: key, result }));
|
||||
};
|
||||
export default processCSV;
|
||||
Reference in New Issue
Block a user