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

Function mapper

ark/schema/shared/codecs.ts:63–75  ·  view source on GitHub ↗
(kind, inner, ctx)

Source from the content-addressed store, hash-verified

61 const branchTfs: boolean[][] = []
62 const headTfs: boolean[] = []
63 const mapper: DeepNodeTransformation = (kind, inner, ctx) =>
64 kind === "morph" ?
65 invert(inner as never, headTfs.pop()!, node.$, mapper, ctx)
66 : kind === "optional" && "default" in inner ?
67 node.$.node("required", {
68 ...omit(inner as Optional.Inner, { default: 1 }),
69 value: decodedValueOf((inner as Optional.Inner).value, node.$)
70 })
71 : kind === "structure" ? requireDefaulted(inner as never)
72 : kind === "sequence" ? requireDefaultables(inner as never, node.$)
73 : kind === "union" ?
74 encodeUnion(inner as Union.Inner, branchTfs.pop()!, node.$)
75 : (inner as never)
76 return node.transform(mapper, {
77 shouldTf: n => {
78 const tfs = n.tfs || (n.is("optional") && n.hasDef())

Callers 2

_tfFunction · 0.85
configureRefsFunction · 0.85

Calls 8

omitFunction · 0.90
decodedValueOfFunction · 0.85
requireDefaultedFunction · 0.85
requireDefaultablesFunction · 0.85
encodeUnionFunction · 0.85
popMethod · 0.80
nodeMethod · 0.80
invertFunction · 0.70

Tested by

no test coverage detected