(field: string, oldValue: unknown, newValue: unknown)
| 396 | }; |
| 397 | |
| 398 | const compare = (field: string, oldValue: unknown, newValue: unknown) => { |
| 399 | const changed = field.startsWith("cost.") |
| 400 | ? ( |
| 401 | oldValue === undefined && newValue === undefined |
| 402 | ? false |
| 403 | : oldValue === undefined || newValue === undefined |
| 404 | ? true |
| 405 | : Math.abs((oldValue as number) - (newValue as number)) > epsilon |
| 406 | ) |
| 407 | : JSON.stringify(oldValue) !== JSON.stringify(newValue); |
| 408 | |
| 409 | if (changed) { |
| 410 | changes.push({ |
| 411 | field, |
| 412 | oldValue: formatValue(oldValue), |
| 413 | newValue: formatValue(newValue), |
| 414 | }); |
| 415 | } |
| 416 | }; |
| 417 | |
| 418 | compare("name", existing.name, merged.name); |
| 419 | compare("family", existing.family, merged.family); |
no test coverage detected