From 78d26881ba552173d4db0e08304d54e70c3ba26c Mon Sep 17 00:00:00 2001 From: Francis Okoyo Date: Thu, 30 Sep 2021 09:25:17 -0400 Subject: [PATCH] Fixed NaN `:rate` and 0.0 `:eta` when `curr` is set. - Setting the current progress index to anything other than `0` will cause the value of `this.start` to be undefined. This causes the calculation for `:eta` and `:rate` to produce useless information. - Replaced conditional to set `start` only when the progress is ticked when `current` == 0. - We will always set the `start` time on first tick anyway. --- lib/node-progress.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node-progress.js b/lib/node-progress.js index 8eb0740..c77c80d 100644 --- a/lib/node-progress.js +++ b/lib/node-progress.js @@ -89,7 +89,7 @@ ProgressBar.prototype.tick = function(len, tokens){ if (tokens) this.tokens = tokens; // start time for eta - if (0 == this.curr) this.start = new Date; + if (!this.start) this.start = new Date; this.curr += len