refactor to ES modules

This commit is contained in:
2023-12-02 13:27:37 +01:00
parent 1137d26cd6
commit 308baf0b16
8 changed files with 206 additions and 139 deletions
+21
View File
@@ -0,0 +1,21 @@
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')
}
}