diff options
| author | Max Isom <[email protected]> | 2020-03-18 22:29:43 -0500 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2020-03-18 22:29:43 -0500 |
| commit | 7f39642c49b55dc1c29eb07962c79797eee66270 (patch) | |
| tree | 05ed46a3c9192158a3aa94522775e7415023e2dd /src/utils | |
| parent | 035737312360279efd5026b225f30ef14aa55abf (diff) | |
| download | muse-7f39642c49b55dc1c29eb07962c79797eee66270.tar.xz muse-7f39642c49b55dc1c29eb07962c79797eee66270.zip | |
Add queue output, various bug fixes
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/get-progress-bar.ts | 15 | ||||
| -rw-r--r-- | src/utils/time.ts | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/utils/get-progress-bar.ts b/src/utils/get-progress-bar.ts new file mode 100644 index 0000000..7db3dd0 --- /dev/null +++ b/src/utils/get-progress-bar.ts @@ -0,0 +1,15 @@ +export default (width: number, progress: number): string => { + const dotPosition = Math.floor(width * progress); + + let res = ''; + + for (let i = 0; i < width; i++) { + if (i === dotPosition) { + res += '🔘'; + } else { + res += '▬'; + } + } + + return res; +}; diff --git a/src/utils/time.ts b/src/utils/time.ts new file mode 100644 index 0000000..a54bfa7 --- /dev/null +++ b/src/utils/time.ts @@ -0,0 +1,15 @@ +export const prettyTime = (seconds: number): string => { + const nSeconds = seconds % 60; + const nMinutes = Math.floor(seconds / 60); + const nHours = Math.floor(nMinutes / 60); + + let res = ''; + + if (nHours !== 0) { + res += `${Math.round(nHours).toString().padStart(2, '0')}:`; + } + + res += `${Math.round(nMinutes).toString().padStart(2, '0')}:${Math.round(nSeconds).toString().padStart(2, '0')}`; + + return res; +}; |
