Skip to content

Commit

Permalink
Add head option to specify head character
Browse files Browse the repository at this point in the history
  • Loading branch information
Dineshs91 committed Dec 6, 2015
1 parent d479135 commit 571caf7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/node-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exports = module.exports = ProgressBar;
* - `total` total number of ticks to complete
* - `width` the displayed width of the progress bar defaulting to total
* - `stream` the output stream defaulting to stderr
* - `head` head character defaulting to complete character
* - `complete` completion character defaulting to "="
* - `incomplete` incomplete character defaulting to "-"
* - `renderThrottle` minimum time between updates in milliseconds defaulting to 16
Expand Down Expand Up @@ -59,7 +60,8 @@ function ProgressBar(fmt, options) {
this.clear = options.clear
this.chars = {
complete : options.complete || '=',
incomplete : options.incomplete || '-'
incomplete : options.incomplete || '-',
head : options.head || (options.complete || '=')
};
this.renderThrottle = options.renderThrottle !== 0 ? (options.renderThrottle || 16) : 0;
this.callback = options.callback || function () {};
Expand Down Expand Up @@ -145,6 +147,10 @@ ProgressBar.prototype.render = function (tokens) {
complete = Array(completeLength + 1).join(this.chars.complete);
incomplete = Array(width - completeLength + 1).join(this.chars.incomplete);

/* add head to the complete string */
if(completeLength > 0)
complete = complete.slice(0, -1) + this.chars.head;

/* fill in the actual progress bar */
str = str.replace(':bar', complete + incomplete);

Expand Down

0 comments on commit 571caf7

Please sign in to comment.