feat: reworked the api, added duration/current in seconds + shuffle & repeat

This commit is contained in:
2024-05-05 20:12:10 +02:00
parent 000853414e
commit db8a2c2741
15 changed files with 199 additions and 94 deletions

View File

@@ -0,0 +1,14 @@
/**
* Convert a HH:MM:SS string (or variants such as MM:SS or SS) to plain seconds
* @param duration in HH:MM:SS format
* @returns number of seconds in duration
*/
export const convertDurationToSeconds = (duration: string) => {
return duration
.split(":")
.reverse()
.map((val) => Number(val))
.reduce((previous, current, index) => {
return index === 0 ? current : previous + current * Math.pow(60, index);
}, 0);
};