INNER CODE UNIT · TypeScript
current
akirarika/milkio · packages/cookbook/src/progress/index.ts:113
current = Math.min(value / progress.totalUnits, 1);
if (progress.timeWaste === 0 && current > 0.4) {
progress.timeWaste = (Date.now() - progress.timeStart) / 1000;
}
} else {
current = 1 - Math.exp((-1 * progress.time) / FALLBACK_SPEED);
current = Math.min(current, FALLBACK_CAP);
}
const permille = Math.floor(current * 1000);
const now = Date.now();
const shouldRender = permille !== progress.lastRenderedPermille || now - progress.lastRenderAt > MAX_RENDER_GAP;
if (shouldRender) {
progress.lastRenderedPermille = permille;
progress.lastRenderAt = now;
progress.rate = permille;
progress.current = current;
consola.start(chalk.gray(`[${getRate()}] ${progress.message}`));