minio-worker/util.ts
2025-04-20 02:02:00 +03:00

26 lines
640 B
TypeScript

export function sleepWithCountdown(seconds: number): Promise<void> {
return new Promise((resolve) => {
let remaining = seconds;
const update = () => {
const msg = `⏳ Waiting ${remaining}s...`;
const padded = msg.padEnd(30, " "); // make sure old content is erased
process.stdout.write(`\r${padded}`);
};
update(); // initial print
const interval = setInterval(() => {
remaining--;
if (remaining > 0) {
update();
} else {
clearInterval(interval);
process.stdout.write(`\r✅ Resuming now \n`);
resolve();
}
}, 1000);
});
}