const slog = require('single-line-log').stdout;
class ProgressBar {
constructor(description, barLength) {
this.description = description || 'Progress';
this.barLength = barLength || 25;
}
render (options) {
const percent = (options.completed / options.total).toFixed(4);
const cell_num = Math.floor(percent * this.barLength);
let cell = '';
for (let i = 0; i < cell_num; i++) {
cell += '█';
}
let empty = '';
for (let j = 0; j < this.barLength - cell_num; j++) {
empty += '?';
}
const cmdText = this.description + ': ' + (100 * percent).toFixed(2) + '% ' + cell + empty;
slog(cmdText);
}
}
const awaitTime = async (time) => {
核弹发射代码
最新推荐文章于 2023-06-27 18:52:13 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)