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

Function writeOnto

ark/aot/shadow.ts:752–772  ·  view source on GitHub ↗
(
	state: unknown,
	counterparts: Map<object, unknown>,
	received: Set<unknown>,
	visited = new Set<object>()
)

Source from the content-addressed store, hash-verified

750}
751
752const writeOnto = (
753 state: unknown,
754 counterparts: Map<object, unknown>,
755 received: Set<unknown>,
756 visited = new Set<object>()
757): void => {
758 if (!hasDomain(state, "object") || visited.has(state)) return
759 visited.add(state)
760 const values = state as Record<PropertyKey, unknown>
761 for (const k of Reflect.ownKeys(state))
762 writeOnto(values[k], counterparts, received, visited)
763 // e.g. an object the call created, standing for none of the validator's
764 if (!received.has(state)) return
765 const target = counterparts.get(state) as Record<PropertyKey, unknown>
766 for (const k of Reflect.ownKeys(target))
767 if (!Object.prototype.hasOwnProperty.call(state, k)) delete target[k]
768 for (const k of Reflect.ownKeys(state)) {
769 const next = copyOf(values[k], counterparts)
770 if (!Object.is(target[k], next)) target[k] = next
771 }
772}
773
774const describeCall = (
775 call: Pick<Call, "callee" | "args"> & Partial<Pick<Call, "copies" | "ctx">>

Callers 1

writeAllFunction · 0.85

Calls 7

hasDomainFunction · 0.90
callMethod · 0.80
isMethod · 0.80
copyOfFunction · 0.70
getMethod · 0.65
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected