MCPcopy Create free account
hub / github.com/Nutlope/llamacoder / buildFileTree

Function buildFileTree

components/syntax-highlighter.tsx:207–226  ·  view source on GitHub ↗
(
  files: Array<{ path: string; content: string; language: string }>,
)

Source from the content-addressed store, hash-verified

205}
206
207function buildFileTree(
208 files: Array<{ path: string; content: string; language: string }>,
209) {
210 const tree: any = {};
211
212 files.forEach((file) => {
213 const parts = file.path.split("/");
214 let current = tree;
215
216 parts.forEach((part, index) => {
217 if (!current[part]) {
218 current[part] =
219 index === parts.length - 1 ? { ...file, isFile: true } : {};
220 }
221 current = current[part];
222 });
223 });
224
225 return tree;
226}
227
228function FileTree({
229 tree,

Callers 1

SyntaxHighlighterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected