Skip to content

Commit

Permalink
Merge pull request #183 from mleguen/182-force-render-on-completion
Browse files Browse the repository at this point in the history
Add force option to render and use it on complete
  • Loading branch information
westwood846 authored Dec 3, 2018
2 parents 4951391 + 06d8b95 commit 3a01c87
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/node-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ProgressBar.prototype.tick = function(len, tokens){

// progress complete
if (this.curr >= this.total) {
this.render();
this.render(undefined, true);
this.complete = true;
this.terminate();
this.callback(this);
Expand All @@ -114,14 +114,14 @@ ProgressBar.prototype.tick = function(len, tokens){
* @api public
*/

ProgressBar.prototype.render = function (tokens) {
ProgressBar.prototype.render = function (tokens, force = false) {

This comment has been minimized.

Copy link
@gfguthrie

gfguthrie Dec 5, 2018

This breaks Node 4. Pull req #186 opened to fix.

if (tokens) this.tokens = tokens;

if (!this.stream.isTTY) return;

var now = Date.now();
var delta = now - this.lastRender;
if (delta < this.renderThrottle) {
if (!force && (delta < this.renderThrottle)) {
return;
} else {
this.lastRender = now;
Expand Down

0 comments on commit 3a01c87

Please sign in to comment.