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
sso-timer/js/transform.js
T
2023-12-02 13:28:48 +01:00

22 lines
609 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')
}
}