⚡ Zero-dependency plcbundle library exclusively for Bun
1const counts: Record<string, number>= {}
2
3export function process({ op }: { op: any }) {
4
5 if (!op.operation?.services) {
6 return
7 }
8 for (const key of Object.keys(op.operation.services)) {
9 if (!counts[key]) {
10 counts[key] = 1
11 } else {
12 counts[key] += 1
13 }
14 }
15}
16
17export function prepare() {
18 return { counts }
19}
20
21export function finalize(results: any, { aggregate }: any) {
22 console.log(Object.fromEntries(Object.entries(aggregate(results.map((r: any) => r.data.counts))).sort((a, b) => a[1] < b[1] ? 1 : -1)))
23}