mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 10:25:06 +03:00
14 lines
334 B
JavaScript
14 lines
334 B
JavaScript
function RoundToFixDecimals(value, numDecimals = 5) {
|
|
function addZero(s, size) {
|
|
while (s.length <= (size || 2)) { s = s + "0"; }
|
|
return s;
|
|
}
|
|
|
|
const temp = addZero("1", numDecimals)
|
|
const tempNum = parseInt(temp, 10)
|
|
return Math.round((value + Number.EPSILON) * tempNum) / tempNum
|
|
}
|
|
|
|
export {
|
|
RoundToFixDecimals
|
|
} |