forked from google-gemini/gemini-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatistics-helper.ts
More file actions
26 lines (22 loc) · 791 Bytes
/
Copy pathstatistics-helper.ts
File metadata and controls
26 lines (22 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
export function countMatchingIds<T extends { sessionId: string }>(
items: T[],
expectedIds: string[],
): number {
const expected = new Set(expectedIds);
return items.filter((item) => expected.has(item.sessionId)).length;
}
export function roundStat(value: number | null): number | null {
return value === null ? null : Number(value.toFixed(4));
}
export function average(values: number[]): number {
return values.reduce((sum, value) => sum + value, 0) / values.length;
}
export function averageNullable(values: Array<number | null>): number | null {
const numericValues = values.filter((value) => value !== null);
return numericValues.length === 0 ? null : average(numericValues);
}