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

Function createStructuralWriter

ark/schema/structure/structure.ts:129–142  ·  view source on GitHub ↗
(childStringProp: "expression" | "description")

Source from the content-addressed store, hash-verified

127
128const createStructuralWriter =
129 (childStringProp: "expression" | "description") => (node: StructureNode) => {
130 if (node.props.length || node.index) {
131 const parts = node.index?.map(index => index[childStringProp]) ?? []
132 for (const prop of node.props) parts.push(prop[childStringProp])
133
134 if (node.undeclared) parts.push(`+ (undeclared): ${node.undeclared}`)
135
136 const objectLiteralDescription = `{ ${parts.join(", ")} }`
137 return node.sequence ?
138 `${objectLiteralDescription} & ${node.sequence.description}`
139 : objectLiteralDescription
140 }
141 return node.sequence?.description ?? "{}"
142 }
143
144const structuralDescription = createStructuralWriter("description")
145const structuralExpression = createStructuralWriter("expression")

Callers 1

structure.tsFile · 0.85

Calls 2

mapMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected