MCPcopy Create free account
hub / github.com/microsoft/Webwright / countBy

Function countBy

assets/compare_trajectory/app.js:103–115  ·  view source on GitHub ↗
(items, selector)

Source from the content-addressed store, hash-verified

101}
102
103function countBy(items, selector) {
104 const counts = new Map();
105 for (const item of items) {
106 const key = selector(item);
107 if (!key) {
108 continue;
109 }
110 counts.set(key, (counts.get(key) || 0) + 1);
111 }
112 return Array.from(counts.entries())
113 .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
114 .map(([label, value]) => ({ label, value }));
115}
116
117function toBarRows(rows, limit = 6) {
118 const subset = rows.slice(0, limit);

Callers 1

finalizeTraceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected