@syngrisi/syngrisi
Version:
Syngrisi - Visual Testing Tool
34 lines • 972 B
JavaScript
// src/server/utils/ProgressBar.ts
var ProgressBar = class {
length;
percentLenght;
prevPercent;
currentPercent;
progressString;
constructor(length) {
this.length = length;
this.percentLenght = parseFloat((length / 100).toString());
this.prevPercent = 0;
this.currentPercent = 0;
this.progressString = "";
}
isChange(current) {
this.currentPercent = parseInt((current / this.percentLenght).toString(), 10);
if (this.prevPercent === this.currentPercent) {
return false;
}
this.prevPercent = this.currentPercent;
this.progressString += "#";
return true;
}
writeIfChange(index, count, fn, res) {
if (this.isChange(index)) {
const placeholderString = Array.from(new Array(99 - this.currentPercent)).reduce((accum) => accum += ".", "");
fn(`[${this.progressString}${placeholderString}](${index}/${count})`, res);
}
}
};
export {
ProgressBar
};
//# sourceMappingURL=ProgressBar.js.map