UNPKG

@acrool/js-utils

Version:

Common javascript utils methods for project development

21 lines (20 loc) 573 B
function o(r, n = 2) { const t = Number(r).toString().split("."), c = t[0]; let i = t[1] ?? ""; return i = i.padEnd(n, "0").slice(0, n), `${c}.${i}`; } function s(r = 0, n = !1) { const t = (n ? o(r) : Math.floor(r)).toString().split("."); return t[0] = t[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","), t.join("."); } function a(r) { let n, e; return r.forEach((t) => { n = n ? t[0] > n ? t[0] : n : t[0], e = e ? t[1] < e ? t[1] : e : t[1]; }), { min: n ?? 0, max: e ?? 0 }; } export { s as formatCurrency, a as intersectionMin, o as numToDecimal2 };