MCPcopy Create free account
hub / github.com/denoland/std / #createFormatterObject

Method #createFormatterObject

cli/unstable_progress_bar.ts:248–272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

246 this.#print();
247 }
248 #createFormatterObject() {
249 const time = Date.now() - this.#startTime;
250
251 const ratio = clamp(this.value / this.max, 0, 1);
252 const size = Math.trunc(ratio * this.#barLength);
253 const fillChars = this.#fillChar.repeat(size);
254 const emptyChars = this.#emptyChar.repeat(this.#barLength - size);
255
256 return {
257 get styledTime() {
258 const minutes = (this.time / 1000 / 60 | 0).toString().padStart(2, "0");
259 const seconds = (this.time / 1000 % 60 | 0).toString().padStart(2, "0");
260 return `${minutes}:${seconds}`;
261 },
262 get styledData() {
263 return formatUnitFraction(this.value, this.max);
264 },
265 progressBar: `${fillChars}${emptyChars}`,
266 time,
267 previousTime: this.#previousTime,
268 value: this.value,
269 previousValue: this.#previousValue,
270 max: this.max,
271 };
272 }
273 async #print(): Promise<void> {
274 const formatter = this.#createFormatterObject();
275 const output = this.#formatter(formatter);

Callers 1

#printMethod · 0.95

Calls 2

nowMethod · 0.80
clampFunction · 0.70

Tested by

no test coverage detected