MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / groupByDirectory

Function groupByDirectory

src/core/walker.ts:92–103  ·  view source on GitHub ↗
(entries: FileEntry[])

Source from the content-addressed store, hash-verified

90}
91
92export function groupByDirectory(entries: FileEntry[]): Map<string, FileEntry[]> {
93 const groups = new Map<string, FileEntry[]>();
94 for (const entry of entries) {
95 const dir = entry.relativePath.includes("/")
96 ? entry.relativePath.substring(0, entry.relativePath.lastIndexOf("/"))
97 : ".";
98 const existing = groups.get(dir) ?? [];
99 existing.push(entry);
100 groups.set(dir, existing);
101 }
102 return groups;
103}

Callers 2

walker.test.mjsFile · 0.85
walker.demo.mjsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected