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

Function transformsKeyTwice

ark/schema/shared/inPlace.ts:213–226  ·  view source on GitHub ↗
(structure: StructureNode)

Source from the content-addressed store, hash-verified

211
212// a key two constraints transform, each reading the value as it received it
213const transformsKeyTwice = (structure: StructureNode): boolean => {
214 const writes = (node: BaseNode) =>
215 node.hasAlias ||
216 node.references.some(
217 reference => reference.is("structure") && reference.tfs
218 )
219 const index = structure.index?.filter(index => index.value.tfs) ?? []
220 if (!index.length) return false
221 if (index.length > 1 && index.some(index => writes(index.value))) return true
222 return structure.props.some(prop => {
223 const steps = structure.tfsOf(prop)
224 return steps.length > 1 && steps.some(step => writes(step.node))
225 })
226}
227
228// a reader checked after the writer receives what it wrote
229const overlaps = (writer: BaseRoot, reader: BaseRoot): boolean => {

Callers 1

writesSoundlyFunction · 0.85

Calls 3

writesFunction · 0.85
filterMethod · 0.80
tfsOfMethod · 0.80

Tested by

no test coverage detected