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

Function copyOf

ark/aot/settingsValidators.ts:427–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425 ...Object.getOwnPropertySymbols(data)
426]
427var copyOf = data => {
428 if (isArray(data)) {
429 const copy2 = Array.prototype.slice.call(data)
430 const keys = Object.keys(data)
431 return (
432 keys.length !== copy2.length ||
433 keys[copy2.length - 1] !== `${copy2.length - 1}` ||
434 Object.getOwnPropertySymbols(data).length
435 ) ?
436 Object.defineProperties(
437 copy2,
438 Object.getOwnPropertyDescriptors({ ...data })
439 )
440 : copy2
441 }
442 const prototype = Object.getPrototypeOf(data)
443 if (prototype === Object.prototype) return { ...data }
444 if (joinsKept && copiedInPlace?.has(data)) return data
445 if (Object.prototype.toString.call(data) === "[object Object]")
446 return Object.setPrototypeOf({ ...data }, prototype)
447 if (!joinsKept || !copiedInPlace) return data
448 const copy = /* @__PURE__ */ Object.create(null)
449 for (const k of deletableKeysOf(data)) copy[k] = data[k]
450 copiedInPlace.set(copy, data)
451 return copy
452}
453var setOwnValue = (out, k, value) => {
454 "use strict"
455 if (k in out && !hasOwn(out, k)) defineValue(out, k, value)

Callers 3

writtenPropsFunction · 0.70
writtenValuesFunction · 0.70
deletesFunction · 0.70

Calls 4

callMethod · 0.80
deletableKeysOfFunction · 0.70
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected