mirror of
https://gitlab.com/bramw/baserow.git
synced 2024-11-21 23:37:55 +00:00
18 lines
390 B
JavaScript
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))
|
|
}
|