This repository has been archived on 2026-05-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2023-12-02 14:08:54 +01:00

30 lines
706 B
JavaScript

export default class Transform {
static championshipsToLocations(championships) {
return Transform.unique(Transform.flatten(championships))
}
static flatten(object) {
return Object.values(object).reduce((arr, t) => arr.concat(Object.values(t)), [])
}
static unique(array) {
return [...new Set(array)]
}
static dropChampionshipsBefore(championshipsToday, time) {
return Object.keys(championshipsToday).filter((t) => parseInt(t) >= time)
}
static time(time) {
return Math.floor(time/60).toString().padStart(2, '0') + ":" + (time % 60).toString().padStart(2, '0')
}
static stopAtZero(number) {
if (number > 0) {
return number
}
return 0
}
}