| 4 | type Diff = SnapshotFileDiff | VcsFileDiff |
| 5 | |
| 6 | function diff(value: unknown): value is Diff { |
| 7 | if (!value || typeof value !== "object" || Array.isArray(value)) return false |
| 8 | if (!("file" in value) || typeof value.file !== "string") return false |
| 9 | if (!("patch" in value) || typeof value.patch !== "string") return false |
| 10 | if (!("additions" in value) || typeof value.additions !== "number") return false |
| 11 | if (!("deletions" in value) || typeof value.deletions !== "number") return false |
| 12 | if (!("status" in value) || value.status === undefined) return true |
| 13 | return value.status === "added" || value.status === "deleted" || value.status === "modified" |
| 14 | } |
| 15 | |
| 16 | function object(value: unknown): value is Record<string, unknown> { |
| 17 | return !!value && typeof value === "object" && !Array.isArray(value) |