Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions cli/unstable_progress_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,10 @@ export interface ProgressBarFormatter {
* The duration of the progress bar.
*/
time: number;
/**
* The duration passed to the last call.
*/
previousTime: number;
/**
* The current value the progress bar is sitting at.
*/
value: number;
/**
* The value passed to the last call.
*/
previousValue: number;
/**
* The max value expected to receive.
*/
Expand Down Expand Up @@ -202,8 +194,6 @@ export class ProgressBar {
#writer: WritableStreamDefaultWriter;
#id: number;
#startTime: number;
#lastTime: number;
#lastValue: number;
#barLength: number;
#fillChar: string;
#emptyChar: string;
Expand Down Expand Up @@ -250,8 +240,6 @@ export class ProgressBar {
.catch(() => clearInterval(this.#id));
this.#writer = stream.writable.getWriter();
this.#startTime = performance.now();
this.#lastTime = this.#startTime;
this.#lastValue = this.value;

this.#id = setInterval(() => this.#print(), 1000);
this.#print();
Expand All @@ -277,13 +265,9 @@ export class ProgressBar {
},
progressBar: `${fillChars}${emptyChars}`,
time: currentTime - this.#startTime,
previousTime: this.#lastTime - this.#startTime,
value: this.value,
previousValue: this.#lastValue,
max: this.max,
};
this.#lastTime = currentTime;
this.#lastValue = this.value;
await this.#writer.write("\r\u001b[K" + this.#fmt(formatter))
.catch(() => {});
}
Expand Down
23 changes: 0 additions & 23 deletions cli/unstable_progress_bar_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,6 @@ Deno.test("ProgressBar() can remove itself when finished", async () => {
assertEquals(actual, expected);
});

Deno.test("ProgressBar() passes correct values to formatter", async () => {
const { readable, writable } = new TransformStream();
let lastTime: undefined | number = undefined;
let lastValue: undefined | number = undefined;
const bar = new ProgressBar({
writable,
max: 10 * 1000,
keepOpen: false,
fmt(x) {
if (lastTime != undefined) assertEquals(x.previousTime, lastTime);
if (lastValue != undefined) assertEquals(x.previousValue, lastValue);
lastTime = x.time;
lastValue = x.value;
return "";
},
});

for await (const a of getData(10, 1000)) bar.value += a.length;
bar.stop();

await new Response(readable).bytes();
});

Deno.test("ProgressBar() uses correct unit type", async () => {
const units = ["KiB", "MiB", "GiB", "TiB", "PiB"];
let i = 0;
Expand Down
Loading