|
7 | 7 | export interface ProgressBarFormatter {
|
8 | 8 | /**
|
9 | 9 | * A function that returns a formatted version of the duration.
|
10 |
| - * `[mm:ss] ` |
| 10 | + * `[mm:ss]` |
11 | 11 | */
|
12 | 12 | styledTime: () => string;
|
13 | 13 | /**
|
14 | 14 | * A function that returns a formatted version of the data received.
|
15 |
| - * `[0.40/97.66 KiB] ` |
| 15 | + * `[0.40/97.66 KiB]` |
16 | 16 | * @param fractions The number of decimal places the values should have.
|
17 | 17 | */
|
18 | 18 | styledData: (fractions?: number) => string;
|
19 | 19 | /**
|
20 | 20 | * The progress bar string.
|
21 |
| - * Default Style: `[###-------] ` |
| 21 | + * Default Style: `[###-------]` |
22 | 22 | */
|
23 | 23 | progressBar: string;
|
24 | 24 | /**
|
@@ -172,7 +172,7 @@ export class ProgressBar {
|
172 | 172 | fillChar = "#",
|
173 | 173 | emptyChar = "-",
|
174 | 174 | clear = false,
|
175 |
| - fmt = (x) => x.styledTime() + x.progressBar + x.styledData(), |
| 175 | + fmt = (x) => `${x.styledTime()} ${x.progressBar} ${x.styledData()} `, |
176 | 176 | keepOpen = true,
|
177 | 177 | } = options;
|
178 | 178 | this.#value = value;
|
@@ -223,14 +223,14 @@ export class ProgressBar {
|
223 | 223 | styledTime() {
|
224 | 224 | const minutes = (this.time / 1000 / 60 | 0).toString().padStart(2, "0");
|
225 | 225 | const seconds = (this.time / 1000 % 60 | 0).toString().padStart(2, "0");
|
226 |
| - return `[${minutes}:${seconds}] `; |
| 226 | + return `[${minutes}:${seconds}]`; |
227 | 227 | },
|
228 | 228 | styledData: (fractions = 2): string => {
|
229 | 229 | const currentValue = (this.#value / this.#rate).toFixed(fractions);
|
230 | 230 | const maxValue = (this.#max / this.#rate).toFixed(fractions);
|
231 |
| - return `[${currentValue}/${maxValue} ${this.#unit}] `; |
| 231 | + return `[${currentValue}/${maxValue} ${this.#unit}]`; |
232 | 232 | },
|
233 |
| - progressBar: `[${fillChars}${emptyChars}] `, |
| 233 | + progressBar: `[${fillChars}${emptyChars}]`, |
234 | 234 | time: currentTime - this.#startTime,
|
235 | 235 | previousTime: this.#lastTime - this.#startTime,
|
236 | 236 | value: this.#value,
|
|
0 commit comments