(previousValue: T, patchValue: any)
| 289 | }; |
| 290 | |
| 291 | export function handlePatch<T>(previousValue: T, patchValue: any): T { |
| 292 | let reducedValue = previousValue; |
| 293 | |
| 294 | for (let i = 0; i < patchValue.operations.length; i++) { |
| 295 | const patch = patchValue.operations[i]; |
| 296 | patch.location = getLocationPath(patch.location, reducedValue); |
| 297 | const handler = patchHandlers[patch.operation]; |
| 298 | if (!handler) { |
| 299 | throw new Error(`Invalid Operation ${patch.operation}`); |
| 300 | } |
| 301 | reducedValue = handler(reducedValue, patch); |
| 302 | } |
| 303 | |
| 304 | return reducedValue; |
| 305 | } |
| 306 | |
| 307 | export function parsePatchProps( |
| 308 | props: any, |
no test coverage detected
searching dependent graphs…