diff --git a/lib/node-progress.js b/lib/node-progress.js index 8eb0740..417b74c 100644 --- a/lib/node-progress.js +++ b/lib/node-progress.js @@ -1,3 +1,4 @@ + /*! * node-progress * Copyright(c) 2011 TJ Holowaychuk @@ -52,8 +53,10 @@ function ProgressBar(fmt, options) { } else { options = options || {}; if ('string' != typeof fmt) throw new Error('format required'); - if ('number' != typeof options.total) throw new Error('total required'); - } + if (options.total % 1 !== 0 || options.total <= 0) { + throw new Error('format required positive integer'); + } + }s this.fmt = fmt; this.curr = options.curr || 0; @@ -154,7 +157,7 @@ ProgressBar.prototype.render = function (tokens, force) { } var width = Math.min(this.width, availableSpace); - + width = Math.floor(width); /* TODO: the following assumes the user has one ':bar' token */ completeLength = Math.round(width * ratio); complete = Array(Math.max(0, completeLength + 1)).join(this.chars.complete);