progress
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -69,2 +69,3 @@ /*! | ||
this.renderThrottle = options.renderThrottle !== 0 ? (options.renderThrottle || 16) : 0; | ||
this.lastRender = -Infinity; | ||
this.callback = options.callback || function () {}; | ||
@@ -96,10 +97,8 @@ this.tokens = {}; | ||
// 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; | ||
@@ -121,5 +120,2 @@ this.terminate(); | ||
ProgressBar.prototype.render = function (tokens) { | ||
clearTimeout(this.renderThrottleTimeout); | ||
this.renderThrottleTimeout = null; | ||
if (tokens) this.tokens = tokens; | ||
@@ -129,6 +125,14 @@ | ||
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; | ||
@@ -135,0 +139,0 @@ var elapsed = new Date - this.start; |
{ | ||
"name": "progress", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Flexible ascii progress bar", | ||
@@ -17,3 +17,4 @@ "repository": { | ||
"Jordan Scales <scalesjordan@gmail.com>", | ||
"Andrew Rhyne <rhyneandrew@gmail.com>" | ||
"Andrew Rhyne <rhyneandrew@gmail.com>", | ||
"Marco Brack <PapstDonB@Googlemail.com>" | ||
], | ||
@@ -20,0 +21,0 @@ "dependencies": {}, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
202
15418
7