Skip to content

Commit

Permalink
Add a callback option
Browse files Browse the repository at this point in the history
  • Loading branch information
simme authored and jdan committed Oct 9, 2013
1 parent 8c591fe commit 0867c0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
3 changes: 3 additions & 0 deletions lib/node-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down Expand Up @@ -58,6 +59,7 @@ function ProgressBar(fmt, options) {
complete: options.complete || '='
, incomplete: options.incomplete || '-'
};
this.callback = options.callback || function () {};
}

/**
Expand Down Expand Up @@ -86,6 +88,7 @@ ProgressBar.prototype.tick = function(len, tokens){
if (this.curr >= this.total) {
this.complete = true;
this.terminate();
this.callback(this);
return;
}
};
Expand Down

0 comments on commit 0867c0a

Please sign in to comment.