INNER CODE UNIT · JavaScript
fmtSpeed
LeyckerS/moondownloader · web/app.js:171
const fmtSpeed = (mbs) => (mbs >= 1 ? [mbs.toFixed(1), "MB/s"] : [(mbs * 1024).toFixed(0), "KB/s"]);
const fmtEta = (s) => {
s = Math.max(0, Math.round(s));
if (!s) return "—";
if (s >= 3600) return `${Math.floor(s / 3600)}h ${String(Math.floor((s % 3600) / 60)).padStart(2, "0")}m`;
if (s >= 60) return `${Math.floor(s / 60)}m ${String(s % 60).padStart(2, "0")}s`;
return `${s}s`;
};
const fmtClock = (s) => `${Math.floor(s / 60)}m ${String(Math.floor(s % 60)).padStart(2, "0")}s`;
const hostOf = (url) => {
const m = /^[a-z]+:\/\/([^/?#]+)/i.exec(url.trim());
return m ? m[1].toLowerCase() : "";
};
const classify = (url) => {
const h = hostOf(url);
if (h.includes("datanodes.to")) return "dn";
if (h.includes("fuckingfast.co")) return "ff";
return "ot";