UNPKG

pretty-parallel

Version:
37 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProgressReporter = void 0; const tslib_1 = require("tslib"); const ora_1 = tslib_1.__importDefault(require("ora")); const pretty_ms_1 = tslib_1.__importDefault(require("pretty-ms")); const eta_1 = require("./eta"); class ProgressReporter { constructor(totalCount, type) { this.totalCount = totalCount; this.type = type; this.processed = 0; this.message = type === 'check' ? 'Checking formatting' : 'Writing formatting'; this.checkFilesStart = Date.now(); this.checkFiles = (0, ora_1.default)(`${this.message} 0% | 0/${totalCount}`).start(); this.eta = new eta_1.ETA(totalCount, this.checkFilesStart, 0); } update(processed) { const now = Date.now(); this.processed = processed; this.eta.update(now, this.processed, this.totalCount); const percent = Math.floor((this.processed / this.totalCount) * 100); const elapsedMs = now - this.checkFilesStart; this.checkFiles.text = `${this.message}\t${percent}% | ${this.processed}/${this.totalCount} | ETA: ${this.eta.getTime()} | Elapsed: ${(0, pretty_ms_1.default)(elapsedMs)} | ${(this.eta.getRate() * 1000).toFixed(0)} files/s`; } fail(message) { this.checkFiles.fail(message); } warn(message) { this.checkFiles.warn(message); } succeed(message) { this.checkFiles.succeed(message); } } exports.ProgressReporter = ProgressReporter; //# sourceMappingURL=progress-reporter.js.map