From 4f2cd504b87f46dff450ac3042f66f2a2e092508 Mon Sep 17 00:00:00 2001 From: chouchouji <1305974212@qq.com> Date: Sat, 11 Jan 2025 11:03:26 +0800 Subject: [PATCH] refactor: optimize baseRound function --- src/math/round.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/math/round.ts b/src/math/round.ts index de32d57..6f9b1ce 100644 --- a/src/math/round.ts +++ b/src/math/round.ts @@ -4,8 +4,8 @@ export function round(val: number, precision: number = 0) { return baseRound(val, precision, Math.round) } -export function baseRound(val: number, precision: number = 0, fn: (val: number) => number) { - precision = clamp(precision, -292, 292) +export function baseRound(val: number, precision: number, fn: (val: number) => number) { + precision = clamp(precision ?? 0, -292, 292) if (!precision) { return fn(val)