(data: any, l: any, r: any)
| 190 | // what two branches made of data both allow, each a copy without the keys it |
| 191 | // deleted. Written into l's, whose keys r's others follow |
| 192 | const joinKept = (data: any, l: any, r: any): unknown => { |
| 193 | if (l === data || r === data) return data |
| 194 | // a value neither copied, which a getter returned each its own of |
| 195 | if (!hasDomain(l, "object") || !hasDomain(r, "object")) return l |
| 196 | // a branch alone leaves a key deleting doesn't read, like an Error's cause, |
| 197 | // as an object written in place holds it unless it transforms its value. |
| 198 | // So the copies of such an object keep one only where each of them holds it |
| 199 | const inPlace = copiedInPlace?.get(l) |
| 200 | for (const k of deletableKeysOf(r)) { |
| 201 | const kept = r[k] |
| 202 | if (!hasOwn(l, k)) { |
| 203 | if (inPlace && !isDeletableKeyOf(inPlace, k)) continue |
| 204 | // a key l's copy inherits, as from an accessor of its class, is |
| 205 | // defined: assigning it would call a setter, or throw without one |
| 206 | if (k in l) defineValue(l, k, kept) |
| 207 | else l[k] = kept |
| 208 | continue |
| 209 | } |
| 210 | const held = l[k] |
| 211 | if (Object.is(held, kept)) continue |
| 212 | const joined = joinKept(data[k], held, kept) |
| 213 | // joined where it's held, unless r kept all data holds there. Nothing |
| 214 | // is assigned otherwise, as what a getter returned each branch anew |
| 215 | // is neither's copy to write |
| 216 | if (joined !== held) setOwnValue(l, k, joined) |
| 217 | } |
| 218 | if (inPlace) { |
| 219 | for (const k of deletableKeysOf(l)) |
| 220 | if (!hasOwn(r, k) && !isDeletableKeyOf(inPlace, k)) delete l[k] |
| 221 | } |
| 222 | return l |
| 223 | } |
| 224 | |
| 225 | export const setOwnValue = ( |
| 226 | out: object, |
no test coverage detected