MCPcopy Create free account
hub / github.com/npkgz/cli-progress / getProgress

Method getProgress

lib/generic-bar.js:180–199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

178
179 // calculate the actual progress value
180 getProgress(){
181 // calculate the normalized current progress
182 let progress = (this.value/this.total);
183
184 // use relative progress calculation ? range between startValue and total is then used as 100%
185 // startValue (offset) is ignored for calculations
186 if (this.options.progressCalculationRelative){
187 progress = (this.value-this.startValue)/(this.total-this.startValue);
188 }
189
190 // handle NaN Errors caused by total=0. Set to complete in this case
191 if (isNaN(progress)){
192 progress = (this.options && this.options.emptyOnZero) ? 0.0 : 1.0;
193 }
194
195 // limiter
196 progress = Math.min(Math.max(progress, 0.0), 1.0);
197
198 return progress;
199 }
200
201 // update the bar value
202 // increment(delta, payload)

Callers 1

renderMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected