Files

13 lines
360 B
JavaScript

/**
* 通用工具与默认值
*/
export const DEFAULT_VERSION_THRESHOLD = 15
export const DEFAULT_SIZE_THRESHOLD = 500
/** 整数钳制:NaN 回退最小值,越界收敛到 [min, max],四舍五入 */
export function clampInt(v, min, max) {
const n = Number(v)
if (Number.isNaN(n)) return min
return Math.min(max, Math.max(min, Math.round(n)))
}