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

Function jsSetOwnProp

ark/schema/structure/structure.ts:1774–1786  ·  view source on GitHub ↗
(
	js: NodeCompiler,
	target: string,
	key: Key,
	value: string,
	isPlain = false
)

Source from the content-addressed store, hash-verified

1772// assigning "__proto__" or an inherited accessor/read-only property invokes
1773// prototype setters or throws instead of defining an own key
1774const jsSetOwnProp = (
1775 js: NodeCompiler,
1776 target: string,
1777 key: Key,
1778 value: string,
1779 isPlain = false
1780): string =>
1781 key === "__proto__" ?
1782 `Object.defineProperty(${target}, "__proto__", { value: ${value}, writable: true, enumerable: true, configurable: true })`
1783 : key in Object.prototype ?
1784 `${js.ref(setOwnValue)}(${target}, ${js.serialize(key)}, ${value})`
1785 : isPlain ? `${target}${js.prop(key)} = ${value}`
1786 : `Object.getPrototypeOf(${target}) === Object.prototype ? (${target}${js.prop(key)} = ${value}) : ${js.ref(setOwnValue)}(${target}, ${js.serialize(key)}, ${value})`
1787
1788export const compileDefault = (
1789 js: NodeCompiler,

Callers 7

onChangeMethod · 0.85
copyKeysMethod · 0.85
jsCopyPropsMethod · 0.85
jsDeleteFromCopyMethod · 0.85
jsDeleteTransformMethod · 0.85
storeMethod · 0.85
compileDefaultFunction · 0.85

Calls 2

propMethod · 0.80
refMethod · 0.45

Tested by

no test coverage detected