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

Function t

ark/type/checkers.ts:1349–1376  ·  view source on GitHub ↗
(data, ctx)

Source from the content-addressed store, hash-verified

1347 const headReadsCtx = headT?.c
1348 const pipes = steps.map(step => step.p)
1349 const t: Transform = (data, ctx) => {
1350 let result = data
1351 if (headT) {
1352 const issues = ctx?.errN
1353 result = headReadsCtx ? headT(data, ctx) : headT(data)
1354 if (result instanceof TransformErrors) {
1355 if (!ctx) return result
1356 addMorphErrs(ctx, result)
1357 return data
1358 }
1359 if (ctx?.errN > issues) return data
1360 }
1361 for (let i = 0; i < steps.length; i++) {
1362 const step = steps[i]
1363 const morphed: any = step(result, ctx)
1364 if (
1365 pipes[i] ?
1366 ctx._errors !== undefined && morphed === ctx._errors
1367 : morphed instanceof ArkErrors
1368 ) {
1369 if (!ctx) return new TransformErrors(morphed, result)
1370 addErrors(ctx, morphed)
1371 return data
1372 }
1373 result = morphed
1374 }
1375 return result
1376 }
1377 t.e = applyMorphAt
1378 if (pipes.includes(1) || headReadsCtx) t.c = 1
1379 checker.t = t

Callers 15

testV8.tsFile · 0.85
failingFunction · 0.85
agreesFunction · 0.85
withContextOfFunction · 0.85
transformedByFunction · 0.85
transformedMethod · 0.85
validatorFunction · 0.85
traverseFunction · 0.85
transformedByFunction · 0.85
checkers.tsFile · 0.85
transformedMethod · 0.85
cyclic.test.tsFile · 0.85

Calls 3

addMorphErrsFunction · 0.90
addErrorsFunction · 0.90
stepFunction · 0.70

Tested by 4

agreesFunction · 0.68
traverseFunction · 0.68
observeFunction · 0.68
checkedFunction · 0.68