INNER CODE UNIT · JavaScript
elide
LeyckerS/moondownloader · web/app.js:194
function elide(name, head = 34, tail = 22) {
if (name.length <= head + tail + 1) return name;
return name.slice(0, head) + "…" + name.slice(-tail);
}
/* Animated counter. The number is the thing the operator stares at; snapping it
between two values hides how fast it is actually moving. */
function roll(el, to, fmt) {
const from = Number(el.dataset.v || 0);
if (!isFinite(to)) return;
if (Math.abs(to - from) < 1e-4) { el.textContent = fmt(to); return; }
cancelAnimationFrame(el._raf);
const t0 = performance.now();
const dur = 340;
const tick = (now) => {
const k = Math.min(1, (now - t0) / dur);
const eased = 1 - Math.pow(1 - k, 3);
el.textContent = fmt(from + (to - from) * eased);