| 750 | } |
| 751 | |
| 752 | const 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 | |
| 774 | const describeCall = ( |
| 775 | call: Pick<Call, "callee" | "args"> & Partial<Pick<Call, "copies" | "ctx">> |