cli-progress
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -0,1 +1,4 @@ | ||
### 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 ### | ||
@@ -2,0 +5,0 @@ * Added: `increment()` method to increase the current progress relatively - thanks to [lennym on GitHub](https://github.com/lennym) #6 |
@@ -6,3 +6,5 @@ var _progress = require('./main'); | ||
Example2(function(){ | ||
console.log('\nDemo finished!'); | ||
Example3(function(){ | ||
console.log('\nDemo finished!'); | ||
}); | ||
}); | ||
@@ -74,2 +76,34 @@ }); | ||
}, 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); | ||
} |
@@ -26,2 +26,5 @@ var _readline = require('readline'); | ||
// stop on finish ? | ||
this.stopOnComplete = options.stopOnComplete || false; | ||
// last drawn string - only render on change! | ||
@@ -210,2 +213,5 @@ this.lastDrawnString = null; | ||
} | ||
if (this.value >= this.getTotal() && this.stopOnComplete) { | ||
this.stop(); | ||
} | ||
}; | ||
@@ -212,0 +218,0 @@ |
{ | ||
"name": "cli-progress", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Easy to use Progress-Bar for Command-Line/Terminal Applications", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -138,2 +138,3 @@ CLI-Progress | ||
- `stream` (type:stream) - output stream to use (default: `process.stderr`) | ||
- `stopOnComplete` (type:boolean) - automatically call `stop()` when the value reaches the total (default: false) | ||
- `clearOnComplete` (type:boolean) - clear the progress bar on complete / `stop()` call (default: false) | ||
@@ -140,0 +141,0 @@ - `barsize` (type:int) - the length of the progress bar in chars (default: 40) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18787
322
167