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

Function transformsOnEncode

ark/schema/shared/codecs.ts:90–104  ·  view source on GitHub ↗
(root: BaseRoot)

Source from the content-addressed store, hash-verified

88// whether a branch reaches a transform that survives encoding (morphs and
89// undeclared: "delete"), excluding defaults stripped to required/prefix
90const transformsOnEncode = (root: BaseRoot): boolean => {
91 if (!root.tfs) return false
92 const visited = new Set<BaseNode>()
93 const queue: BaseNode[] = [root]
94 for (let i = 0; i < queue.length; i++) {
95 for (const ref of referencesWithoutCases(queue[i])) {
96 if (visited.has(ref)) continue
97 visited.add(ref)
98 if (ref.is("morph")) return true
99 if (ref.is("structure") && ref.undeclared === "delete") return true
100 if (ref.is("alias") && !ref.isIo) queue.push(ref.resolution)
101 }
102 }
103 return false
104}
105
106const encodeUnion = (
107 inner: Union.Inner,

Callers 2

encoderOfFunction · 0.85
invertFunction · 0.85

Calls 5

referencesWithoutCasesFunction · 0.90
isMethod · 0.80
hasMethod · 0.45
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected