mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-12 15:50:42 -05:00
ProgressWriter: Logic Modifications
- The progress and percentage is now calculated separately. - The progress bar is removed once the operation has completed.
This commit is contained in:
parent
d9fd560a5b
commit
99ea325013
@ -29,21 +29,23 @@ export class ProgressWriter {
|
||||
|
||||
this.count++;
|
||||
|
||||
const progress = Math.floor((this.count / this.total) * 100);
|
||||
const filledChars = Math.floor((progress / 100) * this.maxBarLength);
|
||||
const progress = this.count / this.total;
|
||||
const percent = Math.floor(progress * 100);
|
||||
|
||||
const filledChars = Math.floor(progress * this.maxBarLength);
|
||||
const emptyChars = this.maxBarLength - filledChars;
|
||||
|
||||
const barFill = this.barFillChar.repeat(filledChars);
|
||||
const barEmptySpace = this.barEmptyChar.repeat(emptyChars);
|
||||
|
||||
const progressBar = ` -> ${this.count} / ${this.total} [${barFill}${barEmptySpace}] ${progress}%`;
|
||||
const progressBar = `-> ${this.count} / ${this.total} [${barFill}${barEmptySpace}] ${percent}%`;
|
||||
|
||||
readline.clearLine(process.stdout, 0);
|
||||
readline.cursorTo(process.stdout, 0, null);
|
||||
process.stdout.write(progressBar);
|
||||
|
||||
if (progress === 100) {
|
||||
process.stdout.write("\n");
|
||||
if (percent >= 100) {
|
||||
readline.clearLine(process.stdout, 0);
|
||||
readline.cursorTo(process.stdout, 0, null);
|
||||
this.done = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user