@vbarbarosh/node-helpers
Advanced tools
Comparing version 3.21.1 to 3.22.0
@@ -5,3 +5,3 @@ { | ||
"name": "@vbarbarosh/node-helpers", | ||
"version": "3.21.1", | ||
"version": "3.22.0", | ||
"description": "A set of helpers for JavaScript/Node.js", | ||
@@ -8,0 +8,0 @@ "files": [ |
const format_bytes = require('./format_bytes'); | ||
const format_percents = require('./format_percents'); | ||
const format_seconds = require('./format_seconds'); | ||
const is_number_gt = require('./is_number_gt'); | ||
function format_progress({percents, total, done, rate, eta, duration}) | ||
{ | ||
const bps = rate ? `${format_bytes(rate)}/s` : '~'; | ||
if (total) { | ||
const eta_str = eta ? format_seconds(eta) : '~'; | ||
const bps = is_number_gt(rate, 0) ? `${format_bytes(rate)}/s` : '~'; | ||
if (is_number_gt(total, 0)) { | ||
const eta_str = is_number_gt(eta, 0) ? format_seconds(eta) : '~'; | ||
return `${format_percents(percents)} | ${format_bytes(done)} of ${format_bytes(total)} at ${bps} ETA ${eta_str} duration=${format_seconds(duration)}`; | ||
} | ||
return `${format_bytes(done)} of ~ at ${bps} duration=${format_seconds(duration)}`; | ||
if (is_number_gt(done, 0)) { | ||
return `${format_bytes(done)} of ~ at ${bps} duration=${format_seconds(duration)}`; | ||
} | ||
if (is_number_gt(duration, 0)) { | ||
return `~ duration=${format_seconds(duration)}`; | ||
} | ||
return '~'; | ||
} | ||
module.exports = format_progress; |
109690
164
3161