Skip to content

Commit

Permalink
added stopOnComplete example; version 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiDittrich committed Dec 2, 2016
1 parent 57ea1e0 commit 9c60674
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 1.3.0 ###
* Added: `stopOnComplete` option to automatically call `stop()` when the value reaches the total - thanks to [lennym on GitHub](https://github.com/lennym) #7

### 1.2.0 ###
* Added: `increment()` method to increase the current progress relatively - thanks to [lennym on GitHub](https://github.com/lennym) #6
* Added: ETA time formatting options (mm:ss, hh:mm, ss) - thanks to [lennym on GitHub](https://github.com/lennym) #5
Expand Down
38 changes: 36 additions & 2 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ var _progress = require('./main');
// run the example sequentially! otherwise both will write to stdout/stderr simultaneous !
Example1(function(){
Example2(function(){
console.log('\nDemo finished!');
Example3(function(){
console.log('\nDemo finished!');
});
});
});

Expand Down Expand Up @@ -70,4 +72,36 @@ function Example2(onComplete){
onComplete.apply(this);
}
}, 50);
};
}

function Example3(onComplete){
// EXAMPLE 3 ---------------------------------------------
console.log('\nExample 3 - Stop the Bar Automatically');
// create new progress bar using default values
var b3 = new _progress.Bar({
stopOnComplete: true,
clearOnComplete: true
});
b3.start(200, 0);

// the bar value - will be linear incremented
var value = 0;

// 20ms update rate
var timer = setInterval(function(){
// increment value
value++;

// update the bar value
b3.update(value);

// set limit
if (value >= b3.getTotal()){
// stop timer
clearInterval(timer);

// run complete callback
onComplete.apply(this);
}
}, 20);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cli-progress",
"version": "1.2.0",
"version": "1.3.0",
"description": "Easy to use Progress-Bar for Command-Line/Terminal Applications",
"keywords": [
"cli",
Expand Down

0 comments on commit 9c60674

Please sign in to comment.