Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed logic bug that caused bar to jump one extra space at the end #13

Merged
merged 1 commit into from

2 participants

Dav Glass TJ Holowaychuk
Dav Glass

I noticed while using this in one of my tools that the progress bar would be a static size until the very end and then it would jump out 1-2 characters.

This patch allows the bar to stay the same size and looks better ;)

You can test it by running your first example from the readme and hitting enter a few times to get the old ones above it. You can see at the very end, the bar jumps out.

TJ Holowaychuk tj merged commit 55178e9 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/node-progress.js
4 lib/node-progress.js
View
@@ -84,12 +84,12 @@ ProgressBar.prototype.tick = function(len, tokens){
var percent = this.curr / this.total * 100
, complete = Math.round(this.width * (this.curr / this.total))
- , incomplete = this.width - complete
+ , incomplete
, elapsed = new Date - this.start
, eta = elapsed * (this.total / this.curr - 1)
complete = Array(complete).join(this.chars.complete);
- incomplete = Array(incomplete).join(this.chars.incomplete);
+ incomplete = Array(this.width - complete.length).join(this.chars.incomplete);
var str = this.fmt
.replace(':bar', complete + incomplete)
Something went wrong with that request. Please try again.