Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayanEmzed committed Feb 4, 2022
1 parent cac2055 commit f4303e0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit f4303e0

Please sign in to comment.