MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / rankMatch

Function rankMatch

projects/runtime-node/src/localFiles.ts:100–112  ·  view source on GitHub ↗
(pathname: string, query: string)

Source from the content-addressed store, hash-verified

98}
99
100function rankMatch(pathname: string, query: string): number {
101 if (!query) return 0
102 const lowerPath = pathname.toLowerCase()
103 const lowerQuery = query.toLowerCase()
104 const index = lowerPath.indexOf(lowerQuery)
105 if (index >= 0) return index
106 let queryIndex = 0
107 for (const char of lowerPath) {
108 if (char === lowerQuery[queryIndex]) queryIndex += 1
109 if (queryIndex === lowerQuery.length) return lowerPath.length
110 }
111 return Number.POSITIVE_INFINITY
112}
113
114export function createRuntimeNodeLocalFilesAdapter(): RuntimeNodeFilesAdapter {
115 return {

Callers 1

fuzzySearchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected