mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
11 lines
367 B
TypeScript
11 lines
367 B
TypeScript
interface TopListItemEntity {
|
|
count: number;
|
|
}
|
|
|
|
/**
|
|
* Get max count for top list. Returns at least 1 to make sure we do not run into issues
|
|
* with empty list (would normally return -Infinity) or 0 (could cause divide by zero error).
|
|
*/
|
|
export function getMaxCount(items: TopListItemEntity[]): number {
|
|
return Math.max(1, ...items.map(({ count }) => count));
|
|
}
|