ramda#groupBy TypeScript Examples

The following examples show how to use ramda#groupBy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: main.ts    From checkstyle-github-action with MIT License 6 votes vote down vote up
function getConclusion(
  annotations: Annotation[]
): 'success' | 'failure' | 'neutral' {
  if (annotations.length === 0) {
    return 'success'
  }

  const annotationsByLevel: {[p: string]: Annotation[]} = groupBy(
    a => a.annotation_level,
    annotations
  )

  if (
    annotationsByLevel[AnnotationLevel.failure] &&
    annotationsByLevel[AnnotationLevel.failure].length
  ) {
    return 'failure'
  } else if (
    annotationsByLevel[AnnotationLevel.warning] &&
    annotationsByLevel[AnnotationLevel.warning].length
  ) {
    return 'neutral'
  }

  return 'success'
}