(
props: any,
previousProps: any
)
| 305 | } |
| 306 | |
| 307 | export function parsePatchProps( |
| 308 | props: any, |
| 309 | previousProps: any |
| 310 | ): Record<string, any> { |
| 311 | if (!is(Object, props)) { |
| 312 | return props; |
| 313 | } |
| 314 | |
| 315 | const patchedProps: any = {}; |
| 316 | |
| 317 | for (const key of Object.keys(props)) { |
| 318 | const val = props[key]; |
| 319 | if (isPatch(val)) { |
| 320 | const previousValue = previousProps[key]; |
| 321 | if (previousValue === undefined) { |
| 322 | throw new Error('Cannot patch undefined'); |
| 323 | } |
| 324 | patchedProps[key] = handlePatch(previousValue, val); |
| 325 | } else { |
| 326 | patchedProps[key] = val; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | return patchedProps; |
| 331 | } |
no test coverage detected
searching dependent graphs…