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