getRoundingMethod.cjs 284 B

1234567891011
  1. "use strict";
  2. exports.getRoundingMethod = getRoundingMethod;
  3. function getRoundingMethod(method) {
  4. return (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. }