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

Function Example3

examples/example.js:78–108  ·  view source on GitHub ↗
(onComplete)

Source from the content-addressed store, hash-verified

76}
77
78function Example3(onComplete){
79 // EXAMPLE 3 ---------------------------------------------
80 console.log('\nExample 3 - Stop the Bar Automatically');
81 // create new progress bar using default values
82 const b3 = new _progress.Bar({
83 stopOnComplete: true,
84 clearOnComplete: true
85 });
86 b3.start(200, 0);
87
88 // the bar value - will be linear incremented
89 let value = 0;
90
91 // 20ms update rate
92 const timer = setInterval(function(){
93 // increment value
94 value++;
95
96 // update the bar value
97 b3.update(value);
98
99 // set limit
100 if (value >= b3.getTotal()){
101 // stop timer
102 clearInterval(timer);
103
104 // run complete callback
105 onComplete.apply(this);
106 }
107 }, 20);
108}
109
110function Example4(onComplete){
111 // EXAMPLE 1 ---------------------------------------------

Callers 1

example.jsFile · 0.85

Calls 4

logMethod · 0.80
getTotalMethod · 0.80
startMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…