Comparing version 1.1.5 to 1.1.6
@@ -0,1 +1,6 @@ | ||
### 1.1.6 / 2014-06-16 | ||
* now prevents progress bar from exceeding TTY width by limiting its width to | ||
the with of the TTY | ||
### 1.1.5 / 2014-03-25 | ||
@@ -2,0 +7,0 @@ |
@@ -112,3 +112,2 @@ /*! | ||
var percent = ratio * 100; | ||
var complete = Math.round(this.width * ratio); | ||
var incomplete; | ||
@@ -118,7 +117,4 @@ var elapsed = new Date - this.start; | ||
complete = Array(complete).join(this.chars.complete); | ||
incomplete = Array(this.width - complete.length).join(this.chars.incomplete); | ||
/* populate the bar template with percentages and timestamps */ | ||
var str = this.fmt | ||
.replace(':bar', complete + incomplete) | ||
.replace(':current', this.curr) | ||
@@ -131,2 +127,14 @@ .replace(':total', this.total) | ||
/* compute the available space for the bar */ | ||
var availableSpace = this.stream.columns - str.replace(':bar', '').length; | ||
var width = Math.min(this.width, availableSpace); | ||
/* TODO: the following assumes the user has one ':bar' token */ | ||
complete = Array(Math.round(width * ratio)).join(this.chars.complete); | ||
incomplete = Array(width - complete.length).join(this.chars.incomplete); | ||
/* fill in the actual progress bar */ | ||
str = str.replace(':bar', complete + incomplete); | ||
/* replace the extra tokens */ | ||
if (tokens) for (var key in tokens) str = str.replace(':' + key, tokens[key]); | ||
@@ -133,0 +141,0 @@ |
{ | ||
"name": "progress" | ||
, "version": "1.1.5" | ||
, "version": "1.1.6" | ||
, "description": "Flexible ascii progress bar" | ||
@@ -5,0 +5,0 @@ , "keywords": ["cli", "progress"] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10744
153