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

Function writePrecompiledUnits

ark/schema/units.ts:1240–1259  ·  view source on GitHub ↗
(
	roots: readonly BaseRoot[]
)

Source from the content-addressed store, hash-verified

1238}
1239
1240export const writePrecompiledUnits = (
1241 roots: readonly BaseRoot[]
1242): Record<string, string> => {
1243 const unitsByKey: Record<string, string | undefined> = {}
1244 const keysById: Record<NodeId, string> = {}
1245 const keyOf = (root: BaseRoot) =>
1246 (keysById[root.id] ??= precompiledKeyOf(root))
1247 for (const root of roots) {
1248 if (root.hasAlias || keyOf(root) in unitsByKey) continue
1249 for (const unit of precompileRootUnits(root)) {
1250 const key = keyOf(unit.roots[0])
1251 if (!(key in unitsByKey))
1252 unitsByKey[key] = writePrecompiledUnit(unit, unitsByKey, keyOf)
1253 }
1254 }
1255 const written: Record<string, string> = {}
1256 for (const key of Object.keys(unitsByKey).sort())
1257 if (unitsByKey[key]) written[key] = unitsByKey[key]
1258 return written
1259}
1260
1261const writePrecompiledUnit = (
1262 unit: RootUnit,

Callers 8

writeCachedUnitsMethod · 0.90
checkBindFunction · 0.90
registerFunction · 0.90
testCache.tsFile · 0.90
emitFunction · 0.90
writeFunction · 0.90
precompileUnitsFunction · 0.90

Calls 4

precompileRootUnitsFunction · 0.85
writePrecompiledUnitFunction · 0.85
sortMethod · 0.80
keyOfFunction · 0.70

Tested by 5

checkBindFunction · 0.72
registerFunction · 0.72
emitFunction · 0.72
writeFunction · 0.72
precompileUnitsFunction · 0.72