UNPKG

date-fns

Version:

Modern JavaScript date utility library

9 lines (8 loc) 229 B
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; }; }