Skip to content

Commit 373c7cd

Browse files
committed
Add new :wheel token
1 parent 491e795 commit 373c7cd

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ These are keys in the options object you can pass to the progress bar along with
4646
These are tokens you can use in the format of your progress bar.
4747

4848
- `:bar` the progress bar itself
49+
- `:wheel` rotating progress indicator
4950
- `:current` current tick number
5051
- `:total` total ticks
5152
- `:elapsed` time elapsed in seconds

examples/indeterminable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var ProgressBar = require('../');
77

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

10-
var bar = new ProgressBar(' [:bar] :current/:total :elapseds :percent :etas', {
10+
var bar = new ProgressBar(' [:wheel][:bar] :current/:total :elapseds :percent :etas', {
1111
complete: '='
1212
, incomplete: ' '
1313
, width: 50

lib/node-progress.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ exports = module.exports = ProgressBar;
3030
* Tokens:
3131
*
3232
* - `:bar` the progress bar itself
33+
* - `:wheel` rotating progress indicator
3334
* - `:current` current tick number
3435
* - `:total` total ticks
3536
* - `:elapsed` time elapsed in seconds
@@ -155,6 +156,7 @@ ProgressBar.prototype.render = function (tokens) {
155156

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

0 commit comments

Comments
 (0)