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

Method update

lib/generic-bar.js:149–177  ·  view source on GitHub ↗
(arg0, arg1 = {})

Source from the content-addressed store, hash-verified

147 // update(value, payload)
148 // update(payload)
149 update(arg0, arg1 = {}){
150 // value set ?
151 // update(value, [payload]);
152 if (typeof arg0 === 'number') {
153 // update value
154 this.value = arg0;
155
156 // add new value; recalculate eta
157 this.eta.update(Date.now(), arg0, this.total);
158 }
159
160 // extract payload
161 // update(value, payload)
162 // update(payload)
163 const payloadData = ((typeof arg0 === 'object') ? arg0 : arg1) || {};
164
165 // update event (before stop() is called)
166 this.emit('update', this.total, this.value);
167
168 // merge payload
169 for (const key in payloadData){
170 this.payload[key] = payloadData[key];
171 }
172
173 // limit reached ? autostop set ?
174 if (this.value >= this.getTotal() && this.options.stopOnComplete) {
175 this.stop();
176 }
177 }
178
179 // calculate the actual progress value
180 getProgress(){

Callers 2

incrementMethod · 0.95
updateETAMethod · 0.45

Calls 2

getTotalMethod · 0.95
stopMethod · 0.95

Tested by

no test coverage detected