Skip to content

Commit

Permalink
Simplier max() fn
Browse files Browse the repository at this point in the history
  • Loading branch information
barvian committed Nov 20, 2024
1 parent 6f53990 commit 611e2cc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/number-flow/src/util/math.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Math.max that handles nullish numbers
export const max = (n1?: number, n2?: number) => {
if (n1 != null && n2 == null) return n1
if (n1 == null && n2 != null) return n2
if (n1 != null && n2 != null) return Math.max(n1, n2)
return null
}
if (n1 == null) return n2
if (n2 == null) return n1
return Math.max(n1, n2)
}

0 comments on commit 611e2cc

Please sign in to comment.