1
0
mirror of https://gitlab.com/bramw/baserow.git synced 2024-11-21 23:37:55 +00:00
bramw_baserow/web-frontend/modules/core/utils/number.js
2023-08-10 11:14:07 +00:00

18 lines
390 B
JavaScript

export const rounder = (digits) => {
return parseInt('1' + Array(digits + 1).join('0'))
}
export const floor = (n, digits = 0) => {
const r = rounder(digits)
return Math.floor(n * r) / r
}
export const ceil = (n, digits = 0) => {
const r = rounder(digits)
return Math.ceil(n * r) / r
}
export const clamp = (value, min, max) => {
return Math.max(min, Math.min(value, max))
}