summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/progress/lib/node-progress.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-10-26 12:35:42 -0400
committerDaniel Bevenius <daniel.bevenius@gmail.com>2018-10-29 07:49:16 +0100
commit2f1c356d7abe4949b5ee68e0724ed7e493fc03e1 (patch)
treeb830b2ba85798b69df5b2750b97e32ce97211bfc /tools/node_modules/eslint/node_modules/progress/lib/node-progress.js
parent9697c0820f015ccf898a3662305a0caa3cd9c208 (diff)
downloadandroid-node-v8-2f1c356d7abe4949b5ee68e0724ed7e493fc03e1.tar.gz
android-node-v8-2f1c356d7abe4949b5ee68e0724ed7e493fc03e1.tar.bz2
android-node-v8-2f1c356d7abe4949b5ee68e0724ed7e493fc03e1.zip
tools: update ESLint to 5.8.0
Update ESLint to 5.8.0. PR-URL: https://github.com/nodejs/node/pull/23904 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/node_modules/progress/lib/node-progress.js')
-rw-r--r--tools/node_modules/eslint/node_modules/progress/lib/node-progress.js22
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/node_modules/eslint/node_modules/progress/lib/node-progress.js b/tools/node_modules/eslint/node_modules/progress/lib/node-progress.js
index 653f711533..5b56c1529d 100644
--- a/tools/node_modules/eslint/node_modules/progress/lib/node-progress.js
+++ b/tools/node_modules/eslint/node_modules/progress/lib/node-progress.js
@@ -66,6 +66,7 @@ function ProgressBar(fmt, options) {
head : options.head || (options.complete || '=')
};
this.renderThrottle = options.renderThrottle !== 0 ? (options.renderThrottle || 16) : 0;
+ this.lastRender = -Infinity;
this.callback = options.callback || function () {};
this.tokens = {};
this.lastDraw = '';
@@ -92,14 +93,12 @@ ProgressBar.prototype.tick = function(len, tokens){
this.curr += len
- // schedule render
- if (!this.renderThrottleTimeout) {
- this.renderThrottleTimeout = setTimeout(this.render.bind(this), this.renderThrottle);
- }
+ // try to render
+ this.render();
// progress complete
if (this.curr >= this.total) {
- if (this.renderThrottleTimeout) this.render();
+ this.render();
this.complete = true;
this.terminate();
this.callback(this);
@@ -116,17 +115,22 @@ ProgressBar.prototype.tick = function(len, tokens){
*/
ProgressBar.prototype.render = function (tokens) {
- clearTimeout(this.renderThrottleTimeout);
- this.renderThrottleTimeout = null;
-
if (tokens) this.tokens = tokens;
if (!this.stream.isTTY) return;
+ var now = Date.now();
+ var delta = now - this.lastRender;
+ if (delta < this.renderThrottle) {
+ return;
+ } else {
+ this.lastRender = now;
+ }
+
var ratio = this.curr / this.total;
ratio = Math.min(Math.max(ratio, 0), 1);
- var percent = ratio * 100;
+ var percent = Math.floor(ratio * 100);
var incomplete, complete, completeLength;
var elapsed = new Date - this.start;
var eta = (percent == 100) ? 0 : elapsed * (this.total / this.curr - 1);