From f4303e0a69b0260733dad66886e1d005de0b6f9b Mon Sep 17 00:00:00 2001 From: ShayanEmzed Date: Fri, 4 Feb 2022 18:09:00 +0330 Subject: [PATCH] fix issue #472 --- src/formatting.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/formatting.js b/src/formatting.js index 270c952f..4f7f3020 100644 --- a/src/formatting.js +++ b/src/formatting.js @@ -824,6 +824,12 @@ function formatOrDefault(providedFormat, defaultFormat) { return providedFormat; } +function round(num, format) { + pow = format.replace('%', '').split('.')[1].length + ans = Math.round((num + Number.EPSILON) * (10 ** pow)) / (10 ** pow) + return ans.toFixed(pow) + '%' +} + module.exports = (numbro) => ({ format: (...args) => format(...args, numbro), getByteUnit: (...args) => getByteUnit(...args, numbro),