(method: RoundingMethod | undefined)
| 1 | import type { RoundingMethod } from "../../types.ts"; |
| 2 | |
| 3 | export function getRoundingMethod(method: RoundingMethod | undefined) { |
| 4 | return (number: number) => { |
| 5 | const round = method ? Math[method] : Math.trunc; |
| 6 | const result = round(number); |
| 7 | // Prevent negative zero |
| 8 | return result === 0 ? 0 : result; |
| 9 | }; |
| 10 | } |
no outgoing calls
no test coverage detected