MCPcopy Index your code
hub / github.com/coder/coder / traverse

Function traverse

site/src/utils/filetree.ts:92–110  ·  view source on GitHub ↗
(
	fileTree: FileTree,
	callback: (
		content: FileTree | string,
		filename: string,
		fullPath: string,
	) => void,
	parent?: string,
)

Source from the content-addressed store, hash-verified

90};
91
92export const traverse = (
93 fileTree: FileTree,
94 callback: (
95 content: FileTree | string,
96 filename: string,
97 fullPath: string,
98 ) => void,
99 parent?: string,
100) => {
101 for (const [filename, content] of Object.entries(fileTree).sort(([a], [b]) =>
102 a.localeCompare(b),
103 )) {
104 const fullPath = parent ? `${parent}/${filename}` : filename;
105 callback(content, filename, fullPath);
106 if (typeof content === "object") {
107 traverse(content, callback, fullPath);
108 }
109 }
110};

Callers 3

filetree.test.tsFile · 0.90
generateVersionFilesFunction · 0.90
findEntrypointFileFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected