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

Method merge

ark/schema/structure/structure.ts:546–561  ·  view source on GitHub ↗
(r: StructureNode)

Source from the content-addressed store, hash-verified

544
545 // as a spread would, keys keep this structure's order and r's new keys follow
546 merge(r: StructureNode): StructureNode {
547 const inner =
548 this.index || r.index || r.sequence ?
549 this.filterKeys("omit", [r.keyof()])
550 // a named key is omitted exactly if r names it
551 : this.withoutKeysOf(r)
552
553 if (r.required) inner.required = append(inner.required, r.required)
554 if (r.optional) inner.optional = append(inner.optional, r.optional)
555 if (r.index) inner.index = append(inner.index, r.index)
556 if (r.sequence) inner.sequence = r.sequence
557 if (r.undeclared) inner.undeclared = r.undeclared
558 else delete inner.undeclared
559 inner.order = [...this.keyOrder, ...r.keyOrder]
560 return this.$.node("structure", inner)
561 }
562
563 private withoutKeysOf(r: StructureNode): Structure.Inner.mutable {
564 const result = makeRootAndArrayPropertiesMutable(this.inner)

Callers

nothing calls this directly

Calls 5

filterKeysMethod · 0.95
withoutKeysOfMethod · 0.95
appendFunction · 0.90
nodeMethod · 0.80
keyofMethod · 0.65

Tested by

no test coverage detected