From 571caf774e05154ebd870bf643ec8df271a80820 Mon Sep 17 00:00:00 2001 From: dinesh Date: Sun, 6 Dec 2015 10:34:24 +0530 Subject: [PATCH 1/2] Add head option to specify head character --- lib/node-progress.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/node-progress.js b/lib/node-progress.js index 3f97e36..e741b5e 100644 --- a/lib/node-progress.js +++ b/lib/node-progress.js @@ -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 @@ -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 () {}; @@ -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); From 407ce637242b02c4ccd8a397a71e8b4b85c70720 Mon Sep 17 00:00:00 2001 From: DINESH S Date: Sun, 18 Dec 2016 12:41:24 +0530 Subject: [PATCH 2/2] Add head option to readme --- Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Readme.md b/Readme.md index 344e38c..5dd9e35 100644 --- a/Readme.md +++ b/Readme.md @@ -33,6 +33,7 @@ These are keys in the options object you can pass to the progress bar along with - `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