MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / countAndSortItems

Function countAndSortItems

source code/utils/exampleCommands.ts:41–51  ·  view source on GitHub ↗
(items: string[], topN: number = 20)

Source from the content-addressed store, hash-verified

39 * sorted by count in descending order, formatted as a string.
40 */
41export function countAndSortItems(items: string[], topN: number = 20): string {
42 const counts = new Map<string, number>()
43 for (const item of items) {
44 counts.set(item, (counts.get(item) || 0) + 1)
45 }
46 return Array.from(counts.entries())
47 .sort((a, b) => b[1] - a[1])
48 .slice(0, topN)
49 .map(([item, count]) => `${count.toString().padStart(6)} ${item}`)
50 .join('\n')
51}
52
53/**
54 * Picks up to `want` basenames from a frequency-sorted list of paths,

Callers

nothing calls this directly

Calls 4

setMethod · 0.80
entriesMethod · 0.80
toStringMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected