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

Method jsCopyProps

ark/schema/structure/structure.ts:1356–1369  ·  view source on GitHub ↗

writes the copy of data's props: an array's copy has only its enumerable props

(
		js: NodeCompiler,
		from: string,
		to: string
	)

Source from the content-addressed store, hash-verified

1354
1355 /** writes the copy of data's props: an array's copy has only its enumerable props */
1356 private jsCopyProps(
1357 js: NodeCompiler,
1358 from: string,
1359 to: string
1360 ): NodeCompiler {
1361 for (const prop of this.inOrder) {
1362 js.if(
1363 `Object.prototype.hasOwnProperty.call(${from}, ${js.serialize(prop.key)})`,
1364 () =>
1365 js.line(jsSetOwnProp(js, to, prop.key, `${from}${js.prop(prop.key)}`))
1366 )
1367 }
1368 return js
1369 }
1370
1371 /** writes the defaults of a sequence's missing elements */
1372 private jsSequenceDefaults(js: NodeCompiler): void {

Callers 2

jsTfMethod · 0.95
copyMethod · 0.95

Calls 4

jsSetOwnPropFunction · 0.85
ifMethod · 0.80
lineMethod · 0.80
propMethod · 0.80

Tested by

no test coverage detected