console/examples/progress-bar.ts

12 lines
313 B
TypeScript
Raw Normal View History

2025-03-14 20:24:43 -07:00
import { withProgress } from "@paperclover/console/Progress";
2025-06-26 23:43:54 -07:00
await withProgress("do a task", async (progress) => {
// mutate the progress object
progress.total = 100;
2025-03-14 20:24:43 -07:00
2025-06-26 23:43:54 -07:00
for (let i = 0; i < progress.total; i++) {
await new Promise((resolve) => setTimeout(resolve, 10));
progress.value += 1;
}
2025-03-14 20:24:43 -07:00
});