Skip to content

Commit

Permalink
Add new :wheel token
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeschastny committed May 22, 2016
1 parent d7c3653 commit 486d1cf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ These are keys in the options object you can pass to the progress bar along with
These are tokens you can use in the format of your progress bar.

- `:bar` the progress bar itself
- `:wheel` rotating progress indicator
- `:current` current tick number
- `:total` total ticks
- `:elapsed` time elapsed in seconds
Expand Down
2 changes: 1 addition & 1 deletion examples/indeterminable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var ProgressBar = require('../');

// simulated download, passing the chunk lengths to tick()

var bar = new ProgressBar(' [:bar] :current/:total :elapseds :percent :etas', {
var bar = new ProgressBar(' [:wheel][:bar] :current/:total :elapseds :percent :etas', {
complete: '='
, incomplete: ' '
, width: 50
Expand Down
2 changes: 2 additions & 0 deletions lib/node-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports = module.exports = ProgressBar;
* Tokens:
*
* - `:bar` the progress bar itself
* - `:wheel` rotating progress indicator
* - `:current` current tick number
* - `:total` total ticks
* - `:elapsed` time elapsed in seconds
Expand Down Expand Up @@ -150,6 +151,7 @@ ProgressBar.prototype.render = function (tokens) {

/* populate the bar template with percentages and timestamps */
var str = this.fmt
.replace(':wheel', this.complete ? '+' : ['/', '-', '\\', '|'][this.updates % 4])
.replace(':current', this.curr)
.replace(':total', this.total > 0 ? this.total : '?')
.replace(':elapsed', isNaN(elapsed) ? '0.0' : (elapsed / 1000).toFixed(1))
Expand Down

0 comments on commit 486d1cf

Please sign in to comment.