diff --git a/Readme.md b/Readme.md index 625cfed..4e08a49 100644 --- a/Readme.md +++ b/Readme.md @@ -33,6 +33,7 @@ var timer = setInterval(function(){ - `complete` completion character defaulting to "=" - `incomplete` incomplete character defaulting to "-" - `clear` option to clear the bar on completion defaulting to false + - `callback` optional function to call when the progress bar completes ## Tokens: diff --git a/lib/node-progress.js b/lib/node-progress.js index b3a7982..8691327 100644 --- a/lib/node-progress.js +++ b/lib/node-progress.js @@ -21,6 +21,7 @@ exports = module.exports = ProgressBar; * - `stream` the output stream defaulting to stdout * - `complete` completion character defaulting to "=" * - `incomplete` incomplete character defaulting to "-" + * - `callback` optional function to call when the progress bar completes * * Tokens: * @@ -58,6 +59,7 @@ function ProgressBar(fmt, options) { complete: options.complete || '=' , incomplete: options.incomplete || '-' }; + this.callback = options.callback || function () {}; } /** @@ -86,6 +88,7 @@ ProgressBar.prototype.tick = function(len, tokens){ if (this.curr >= this.total) { this.complete = true; this.terminate(); + this.callback(this); return; } };