Do not require qualified hitters for sb/cs

This commit is contained in:
Peter 2023-12-26 17:16:40 -05:00
parent dd1d1af8bd
commit 71e7c7fcf7

View File

@ -263,6 +263,9 @@ export default {
return this.getTop10FieldingStatByCategory(stat as keyof FlatFieldingStat) return this.getTop10FieldingStatByCategory(stat as keyof FlatFieldingStat)
}, },
getTop10BattingStatByCategory(stat: keyof BattingStat): BattingStat[] { getTop10BattingStatByCategory(stat: keyof BattingStat): BattingStat[] {
if (['sb', 'cs'].includes(stat)) {
return this.allPlayersBattingStats.concat([]).sort((a, b) => (b[stat] as number) - (a[stat] as number)).slice(0, 10)
}
// concat an empty array so that the existing array is not sorted as a side effect // concat an empty array so that the existing array is not sorted as a side effect
return this.qualifyingBattingStats.concat([]).sort((a, b) => (b[stat] as number) - (a[stat] as number)).slice(0, 10) return this.qualifyingBattingStats.concat([]).sort((a, b) => (b[stat] as number) - (a[stat] as number)).slice(0, 10)
}, },