Skip to content

Commit

Permalink
add fraqOrNull helper
Browse files Browse the repository at this point in the history
  • Loading branch information
vladkens committed Jun 1, 2023
1 parent 39629ca commit 5fd03e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ export const fraq = (val: Fraq): Fraction => {
throw new Error("ValueError")
}

export const fraqOrNull = (val: Fraq): Fraction | null => {
try {
return fraq(val)
} catch (e) {
return null
}
}

export class Fraction {
public _n: number
public _d: number
Expand Down

0 comments on commit 5fd03e7

Please sign in to comment.