Skip to content

Commit 1912448

Browse files
authored
stats.ts: count correctly the number keys remaining to be mapped (#2544)
* Correctly count the number remaining keys to be mapped * Future proof compat key counting (for keys shared across features) * Remove unused variables
1 parent 3d8b4ff commit 1912448

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

scripts/stats.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ export function stats(detailed: boolean = false) {
1717
const featureCount = Object.keys(features).length;
1818

1919
const keys = [];
20-
const doneKeys = Object.values(features).flatMap(
21-
(f) => f.compat_features ?? [],
20+
const doneKeys = Array.from(
21+
new Set(Object.values(features).flatMap((f) => f.compat_features ?? [])),
2222
);
2323
const toDoKeys = [];
24-
const deprecatedNonStandardKeys = [];
2524

2625
for (const f of new Compat().walk()) {
2726
if (!f.id.startsWith("webextensions")) {
@@ -31,8 +30,6 @@ export function stats(detailed: boolean = false) {
3130
if (!doneKeys.includes(f.id)) {
3231
toDoKeys.push(f.id);
3332
}
34-
} else {
35-
deprecatedNonStandardKeys.push(f.id);
3633
}
3734
}
3835
}
@@ -44,7 +41,7 @@ export function stats(detailed: boolean = false) {
4441
const result = {
4542
features: featureCount,
4643
compatKeys: doneKeys.length,
47-
compatKeysUnmapped: toDoKeys.length + deprecatedNonStandardKeys.length,
44+
compatKeysUnmapped: keys.length - doneKeys.length,
4845
compatCoverage: doneKeys.length / keys.length,
4946
compatKeysPerFeatureMean: doneKeys.length / featureCount,
5047
compatKeysPerFeatureMedian: (() => {
@@ -60,9 +57,7 @@ export function stats(detailed: boolean = false) {
6057
frequencyMap.set(size, (frequencyMap.get(size) ?? 0) + 1);
6158
}
6259
return [...frequencyMap.entries()]
63-
.sort(
64-
([sizeA, frequencyA], [sizeB, frequencyB]) => frequencyA - frequencyB,
65-
)
60+
.sort(([, frequencyA], [, frequencyB]) => frequencyA - frequencyB)
6661
.pop()[0];
6762
})(),
6863
currentBurndown: undefined,

0 commit comments

Comments
 (0)