Permalink
Browse files

Fix issue with array dimensions

  • Loading branch information...
1 parent 914f5d4 commit 613a33b64883c7db17ec890fcf529b6c08f7da53 @mixu committed Jul 21, 2014
Showing with 3 additions and 2 deletions.
  1. +3 −2 index.js
View
@@ -10,8 +10,9 @@ function escapeRegExp(string) {
function bar(opts) {
var ratio = opts.current / opts.total,
width = opts.width || 10,
- complete = Array(Math.round(width * ratio)).join('='),
- incomplete = Array(width - complete.length).join(' ');
+ complete = new Array(Math.min(Math.round(width * ratio), width)).join('=');
+
+ var incomplete = new Array(Math.max(0, width - complete.length)).join(' ');
return complete + incomplete;
}

0 comments on commit 613a33b

Please sign in to comment.