getRoundingMethod.js 229 B

12345678
  1. export function getRoundingMethod(method) {
  2. return (number) => {
  3. const round = method ? Math[method] : Math.trunc;
  4. const result = round(number);
  5. // Prevent negative zero
  6. return result === 0 ? 0 : result;
  7. };
  8. }