( target: Record<string, unknown>, table: Table, )
| 177 | } |
| 178 | |
| 179 | function deepAssignTable( |
| 180 | target: Record<string, unknown>, |
| 181 | table: Table, |
| 182 | ) { |
| 183 | const { keys, type, value } = table; |
| 184 | const currentValue = getTargetValue(target, keys); |
| 185 | |
| 186 | if (currentValue === undefined) { |
| 187 | return Object.assign(target, unflat(keys, value)); |
| 188 | } |
| 189 | if (Array.isArray(currentValue)) { |
| 190 | const last = currentValue.at(-1); |
| 191 | deepAssign(last, { type, keys: keys.slice(1), value }); |
| 192 | return target; |
| 193 | } |
| 194 | if (isObject(currentValue)) { |
| 195 | deepAssign(currentValue, { type, keys: keys.slice(1), value }); |
| 196 | return target; |
| 197 | } |
| 198 | throw new Error("Unexpected assign"); |
| 199 | } |
| 200 | |
| 201 | function deepAssignTableArray( |
| 202 | target: Record<string, unknown>, |
no test coverage detected