Skip to content

Commit 3491af1

Browse files
committed
refactor: use es-toolkit clamp in computeMonthlyUsage
Repo guidance is to use es-toolkit for utility functions; clamp expresses the bound directly and is already the convention for this in src/composables/video.
1 parent 3426d71 commit 3491af1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/platform/cloud/subscription/utils/creditsProgress.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { clamp } from 'es-toolkit'
2+
13
interface MonthlyCreditsUsage {
24
/** Credits consumed from the monthly allowance (never negative). */
35
used: number
@@ -21,7 +23,7 @@ export function computeMonthlyUsage(
2123
return { used: 0, remaining: 0, usedFraction: 0 }
2224
}
2325

24-
const remaining = Math.min(monthlyTotal, Math.max(0, monthlyRemaining))
26+
const remaining = clamp(monthlyRemaining, 0, monthlyTotal)
2527
const used = monthlyTotal - remaining
2628

2729
return { used, remaining, usedFraction: used / monthlyTotal }

0 commit comments

Comments
 (0)