UNPKG

dir-analysis-tool

Version:

A comprehensive cross-platform CLI tool for advanced directory analysis with file classification, duplicate detection, large file identification, interactive mode, HTML reports, and multiple export formats. Perfect for disk cleanup, storage audits, and pr

42 lines 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProgressBar = void 0; class ProgressBar { static BAR_LENGTH = 40; lastUpdateTime = 0; updateInterval = 100; show(current, total, currentPath) { const now = Date.now(); if (now - this.lastUpdateTime < this.updateInterval && current !== total) { return; } this.lastUpdateTime = now; const percentage = Math.min(100, Math.round((current / total) * 100)); const filled = Math.round((current / total) * ProgressBar.BAR_LENGTH); const empty = ProgressBar.BAR_LENGTH - filled; const bar = '█'.repeat(filled) + '░'.repeat(empty); const progressText = `[${bar}] ${percentage}% (${current}/${total})`; let output = `\r${progressText}`; if (currentPath) { const maxPathLength = process.stdout.columns ? process.stdout.columns - progressText.length - 5 : 50; const displayPath = currentPath.length > maxPathLength ? '...' + currentPath.slice(-(maxPathLength - 3)) : currentPath; output += ` ${displayPath}`; } process.stdout.write(output); if (current === total) { process.stdout.write('\n'); } } static createCallback(enabled = true) { if (!enabled) return undefined; const progressBar = new ProgressBar(); return (current, total, currentPath) => { progressBar.show(current, total, currentPath); }; } } exports.ProgressBar = ProgressBar; //# sourceMappingURL=progress.js.map