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

Method copyKeys

ark/schema/structure/structure.ts:1334–1351  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1332 jsDeclaredCopy(js: NodeCompiler, written?: Key[]): NodeCompiler {
1333 if (this.sequence || this.writesInto(js)) return js
1334 const copyKeys = () => {
1335 for (const prop of this.inOrder) {
1336 if (written?.includes(prop.key) || prop.key in Object.prototype)
1337 continue
1338 js.line(`${js.ref(keepOwn)}(out, data, ${js.serialize(prop.key)})`)
1339 }
1340 // out inherits these, so only an own one is missing
1341 for (const prop of this.protoProps) {
1342 js.if(
1343 `!Object.prototype.hasOwnProperty.call(out, ${js.serialize(prop.key)}) && Object.prototype.hasOwnProperty.call(data, ${js.serialize(prop.key)})`,
1344 () =>
1345 js.line(
1346 jsSetOwnProp(js, "out", prop.key, `data${js.prop(prop.key)}`)
1347 )
1348 )
1349 }
1350 return js
1351 }
1352 return written === undefined ? js.if("out !== data", copyKeys) : copyKeys()
1353 }
1354

Callers

nothing calls this directly

Calls 5

jsSetOwnPropFunction · 0.85
lineMethod · 0.80
ifMethod · 0.80
propMethod · 0.80
refMethod · 0.45

Tested by

no test coverage detected