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

Function getIo

ark/schema/node.ts:1140–1164  ·  view source on GitHub ↗
(ioKind: "in" | "out")

Source from the content-addressed store, hash-verified

1138 // Should be refactored to use transform
1139 // https://github.com/arktypeio/arktype/issues/1020
1140 getIo(ioKind: "in" | "out"): BaseNode {
1141 if (!this.alters && !(isIoFinal() && this.tfs)) return this as never
1142
1143 const ioInner: Record<any, unknown> = {}
1144 for (const k in this.inner) {
1145 const v = this.inner[k]
1146 const keySchemaImplementation = this.impl.keys[k]
1147
1148 if (keySchemaImplementation.reduceIo)
1149 keySchemaImplementation.reduceIo(ioKind, ioInner, v, this)
1150 else if (keySchemaImplementation.child) {
1151 const childValue = v as listable<BaseNode>
1152
1153 ioInner[k] =
1154 isArray(childValue) ?
1155 childValue.map(child => ioOf(child, ioKind))
1156 : ioOf(childValue, ioKind)
1157 } else ioInner[k] = v
1158 }
1159
1160 // an open alias stands for its input and output alike, so the union reduces once final
1161 return this.$.node(this.kind, ioInner as never, {
1162 reduced: this.is("union") && this.hasAlias && !isIoFinal()
1163 })
1164 }
1165
1166 get innerJson(): JsonStructure {
1167 return (this.c.innerJson ??= possiblyCollapse(

Callers

nothing calls this directly

Calls 5

isIoFinalFunction · 0.90
ioOfFunction · 0.85
nodeMethod · 0.80
isMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected