MCPcopy Create free account
hub / github.com/code-pushup/cli / countOccurrences

Function countOccurrences

packages/utils/src/lib/transform.ts:19–26  ·  view source on GitHub ↗
(
  values: T[],
)

Source from the content-addressed store, hash-verified

17}
18
19export function countOccurrences<T extends PropertyKey>(
20 values: T[],
21): Partial<Record<T, number>> {
22 return values.reduce<Partial<Record<T, number>>>(
23 (acc, value) => ({ ...acc, [value]: (acc[value] ?? 0) + 1 }),
24 {},
25 );
26}
27
28export function distinct<T extends string | number | boolean>(array: T[]): T[] {
29 return [...new Set(array)];

Callers 2

formatIssueSeveritiesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected