( currentMap: Map<string, number>, baselineMap: Map<string, number>, maxDims: number, )
| 128 | * @returns Array of dimension keys, ranked by greatest(current, baseline) |
| 129 | */ |
| 130 | export function selectTopDimensions( |
| 131 | currentMap: Map<string, number>, |
| 132 | baselineMap: Map<string, number>, |
| 133 | maxDims: number, |
| 134 | ): string[] { |
| 135 | // Merge all dimensions from both maps |
| 136 | const allDims = new Set<string>(); |
| 137 | for (const dim of currentMap.keys()) allDims.add(dim); |
| 138 | for (const dim of baselineMap.keys()) allDims.add(dim); |
| 139 | |
| 140 | // Rank by greatest(current, baseline) |
| 141 | const ranked = Array.from(allDims) |
| 142 | .map((dim) => ({ |
| 143 | dim, |
| 144 | maxValue: Math.max(currentMap.get(dim) ?? 0, baselineMap.get(dim) ?? 0), |
| 145 | })) |
| 146 | .sort((a, b) => b.maxValue - a.maxValue) |
| 147 | .slice(0, maxDims) |
| 148 | .map((x) => x.dim); |
| 149 | |
| 150 | return ranked; |
| 151 | } |
no test coverage detected