MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getDirectoryNamesAsync

Function getDirectoryNamesAsync

src/hooks/fileSuggestions.ts:403–418  ·  view source on GitHub ↗
(
  files: string[],
)

Source from the content-addressed store, hash-verified

401 * the main thread for >10ms at a time.
402 */
403export async function getDirectoryNamesAsync(
404 files: string[],
405): Promise<string[]> {
406 const directoryNames = new Set<string>()
407 // Time-based chunking: yield after CHUNK_MS of work so slow machines get
408 // smaller chunks and stay responsive.
409 let chunkStart = performance.now()
410 for (let i = 0; i < files.length; i++) {
411 collectDirectoryNames(files, i, i + 1, directoryNames)
412 if ((i & 0xff) === 0xff && performance.now() - chunkStart > CHUNK_MS) {
413 await yieldToEventLoop()
414 chunkStart = performance.now()
415 }
416 }
417 return [...directoryNames].map(d => d + path.sep)
418}
419
420function collectDirectoryNames(
421 files: string[],

Callers 2

getPathsForSuggestionsFunction · 0.85

Calls 2

collectDirectoryNamesFunction · 0.85
yieldToEventLoopFunction · 0.85

Tested by

no test coverage detected