File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ function ProgressBar(fmt, options) {
6666 head : options . head || ( options . complete || '=' )
6767 } ;
6868 this . renderThrottle = options . renderThrottle !== 0 ? ( options . renderThrottle || 16 ) : 0 ;
69+ this . lastRender = - Infinity ;
6970 this . callback = options . callback || function ( ) { } ;
7071 this . tokens = { } ;
7172 this . lastDraw = '' ;
@@ -92,7 +93,7 @@ ProgressBar.prototype.tick = function(len, tokens){
9293
9394 this . curr += len
9495
95- // schedule render
96+ // try to render
9697 this . render ( ) ;
9798
9899 // progress complete
@@ -118,6 +119,14 @@ ProgressBar.prototype.render = function (tokens) {
118119
119120 if ( ! this . stream . isTTY ) return ;
120121
122+ var now = Date . now ( ) ;
123+ var delta = now - this . lastRender ;
124+ if ( delta < this . renderThrottle ) {
125+ return ;
126+ } else {
127+ this . lastRender = now ;
128+ }
129+
121130 var ratio = this . curr / this . total ;
122131 ratio = Math . min ( Math . max ( ratio , 0 ) , 1 ) ;
123132
You can’t perform that action at this time.
0 commit comments