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

Method tTransform

ark/schema/roots/morph.ts:254–277  ·  view source on GitHub ↗
(data: unknown, ctx: InternalTraversal)

Source from the content-addressed store, hash-verified

252 }
253
254 tTransform(data: unknown, ctx: InternalTraversal): unknown {
255 const errN = ctx.errN
256 let result = this.head?.tfs ? transform(ctx, this.head, data) : data
257 if (ctx.errN > errN) return data
258 const morphs = this.travMorphs
259 for (let i = this.head ? 1 : 0; i < morphs.length; i++) {
260 const morph = morphs[i]
261 if (hasArkKind(morph, "root")) {
262 result = pipe(ctx, morph, result)
263 if (ctx._errors !== undefined && result === ctx._errors) return data
264 continue
265 }
266 const morphed =
267 this.contextFree[i] ?
268 (morph as Morph.ContextFree)(result as never)
269 : callMorph(ctx, this.saying[i] ?? morph, result, this.meta.label)
270 if (morphed instanceof ArkErrors) {
271 addErrors(ctx, morphed)
272 return data
273 }
274 result = morphed
275 }
276 return result
277 }
278
279 /** Check if the morphs of r are equal to those of this node */
280 override sameMorphs(r: MorphNode): boolean {

Callers

nothing calls this directly

Calls 5

transformFunction · 0.90
hasArkKindFunction · 0.90
pipeFunction · 0.90
callMorphFunction · 0.90
addErrorsFunction · 0.90

Tested by

no test coverage detected