MCPcopy Create free account
hub / github.com/arktypeio/arktype / commonDirOf

Function commonDirOf

ark/aot/declare.ts:176–192  ·  view source on GitHub ↗
(
	dirs: readonly string[],
	fallback: string
)

Source from the content-addressed store, hash-verified

174}
175
176export const commonDirOf = (
177 dirs: readonly string[],
178 fallback: string
179): string => {
180 const split = dirs.map(dir => tsPath(dir).replace(/\/+$/, "").split("/"))
181 const first = split[0]
182 if (!first?.length) return fallback
183 let common = 0
184 while (
185 common < first.length &&
186 split.every(parts => parts[common] === first[common])
187 )
188 common++
189 if (common === 0) return fallback
190 const joined = first.slice(0, common).join("/")
191 return /^[A-Za-z]:$/.test(joined) ? `${joined}/` : joined || "/"
192}
193
194const mergeDeclarationResults = (
195 results: Declarations[],

Callers 3

declare.test.tsFile · 0.90
mergeDeclarationResultsFunction · 0.85
sourceRootOfFunction · 0.85

Calls 4

replaceMethod · 0.80
testMethod · 0.80
tsPathFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected