Created
March 31, 2020 12:42
-
-
Save rtang03/376bd053ee024c5969a0bf27226ceb13 to your computer and use it in GitHub Desktop.
type guard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Commit } from '../types'; | |
export const isCommitRecord = (input: unknown): input is Record<string, Commit> => | |
Object.entries(input) | |
.map( | |
([key, value]) => | |
value?.commitId !== undefined && | |
value?.id !== undefined && | |
value?.entityId !== undefined && | |
value?.version !== undefined && | |
value?.entityName !== undefined | |
) | |
.reduce((acc, curr) => curr && acc, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment