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

Method jsForOwnKeys

ark/schema/structure/structure.ts:1601–1620  ·  view source on GitHub ↗

writes a loop of `k` over the own keys of `object`

(
		js: NodeCompiler,
		object: string,
		body: () => NodeCompiler,
		keys = "keys",
		symbols = "symbols",
		withSymbols = this.indexSyms
	)

Source from the content-addressed store, hash-verified

1599
1600 /** writes a loop of `k` over the own keys of `object` */
1601 private jsForOwnKeys(
1602 js: NodeCompiler,
1603 object: string,
1604 body: () => NodeCompiler,
1605 keys = "keys",
1606 symbols = "symbols",
1607 withSymbols = this.indexSyms
1608 ): NodeCompiler {
1609 js.const(keys, `Object.keys(${object})`)
1610 if (withSymbols) {
1611 js.const(symbols, `Object.getOwnPropertySymbols(${object})`).if(
1612 `${symbols}.length`,
1613 () => js.line(`${keys}.push(...${symbols})`)
1614 )
1615 }
1616 return js.for(`i < ${keys}.length`, () => {
1617 js.const("k", `${keys}[i]`)
1618 return body()
1619 })
1620 }
1621
1622 /** writes the check of one of data's entries */
1623 protected jsEntry(

Callers 3

jsTfMethod · 0.95
deletesMethod · 0.95
jsDeleteTransformMethod · 0.95

Calls 4

constMethod · 0.80
ifMethod · 0.80
lineMethod · 0.80
forMethod · 0.80

Tested by

no test coverage detected