-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for indeterminable progress bar (unknown total)
Changes: * new `.done()` method to complete the progress * new `.updates` counter to track `.render()` calls * support for non-positive `.total` * no more `.tick()` calls after progress bar is complete and terminated
- Loading branch information
1 parent
d479135
commit d7c3653
Showing
3 changed files
with
90 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* An example to show how node-progress handles user-specified widths | ||
* which exceed the number of columns in the terminal | ||
*/ | ||
|
||
var ProgressBar = require('../'); | ||
|
||
// simulated download, passing the chunk lengths to tick() | ||
|
||
var bar = new ProgressBar(' [:bar] :current/:total :elapseds :percent :etas', { | ||
complete: '=' | ||
, incomplete: ' ' | ||
, width: 50 | ||
, total: -1 // total number of ticks is unknown | ||
}); | ||
|
||
(function next() { | ||
bar.tick(1); | ||
if (bar.curr >= 150) { | ||
bar.done(); | ||
} else { | ||
setTimeout(next, 50); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters