MCPcopy Index your code
hub / github.com/code-pushup/cli / factorOf

Function factorOf

packages/utils/src/lib/transform.ts:36–45  ·  view source on GitHub ↗
(items: T[], filterFn: (i: T) => boolean)

Source from the content-addressed store, hash-verified

34}
35
36export function factorOf<T>(items: T[], filterFn: (i: T) => boolean): number {
37 const itemCount = items.length;
38 // early exit for empty rows
39 if (!itemCount) {
40 return 1;
41 }
42 const filterCount = items.filter(filterFn).length;
43 // if no rows result from the filter fn we forward return 1 as factor
44 return filterCount === 0 ? 1 : (itemCount - filterCount) / itemCount;
45}
46
47type ArgumentValue = number | string | boolean | string[];
48export type CliArgsObject<T extends object = Record<string, ArgumentValue>> =

Callers 4

scoreByErrorIssuesFunction · 0.90
dependenciesAuditFunction · 0.90
runnerFunctionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected