Skip to content

Instantly share code, notes, and snippets.

@rtang03
Created March 31, 2020 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtang03/376bd053ee024c5969a0bf27226ceb13 to your computer and use it in GitHub Desktop.
Save rtang03/376bd053ee024c5969a0bf27226ceb13 to your computer and use it in GitHub Desktop.
type guard
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