Skip to content

Commit

Permalink
refactor: optimize baseRound function
Browse files Browse the repository at this point in the history
  • Loading branch information
chouchouji committed Jan 11, 2025
1 parent fc7e8b5 commit 4f2cd50
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/math/round.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4f2cd50

Please sign in to comment.