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

Function unitsOf

ark/schema/units.ts:776–804  ·  view source on GitHub ↗
(s: ContentNamingState, opts: UnitOptions)

Source from the content-addressed store, hash-verified

774}
775
776const unitsOf = (s: ContentNamingState, opts: UnitOptions): RootUnit[] => {
777 const units: RootUnit[] = []
778 const unitsById: Record<NodeId, RootUnit> = {}
779 // a component is completed after every component it calls
780 for (const component of s.components) {
781 let written = s.written.units.get(component[0])
782 if (!written || !readsMatch(written, component, s)) {
783 written = writeComponent(component, s, opts)
784 if (!written) continue
785 s.written.units.set(component[0], written)
786 }
787 const unit: RootUnit = {
788 name: written.name,
789 names: s.names,
790 roots: written.roots,
791 traversals: written.declaredTraversals.slice(0, written.roots.length),
792 declared: written.declared,
793 declaredTraversals: written.declaredTraversals,
794 members: written.members,
795 refs: written.refs,
796 dependencies: written.dependencies,
797 identityNamed: s.identityNamed,
798 unitsById
799 }
800 units.push(unit)
801 for (const root of written.roots) unitsById[root.id] = unit
802 }
803 return units
804}
805
806// shared by a later pass reaching the component with the same names and nodes by id
807interface WrittenUnit {

Callers 1

precompileRootUnitsFunction · 0.70

Calls 5

readsMatchFunction · 0.85
writeComponentFunction · 0.85
getMethod · 0.65
setMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected