(rawSize, from='B', decimalFixed=null)
| 391 | } |
| 392 | |
| 393 | export function toPrettySize(rawSize, from='B', decimalFixed=null) { |
| 394 | try { |
| 395 | //if the integer need to be converted to K for thousands, M for millions , B for billions only |
| 396 | if (from == '') { |
| 397 | return Intl.NumberFormat('en', {notation: 'compact'}).format(rawSize); |
| 398 | } |
| 399 | let conVal = convert(rawSize).from(from).toBest(); |
| 400 | conVal.val = Math.round(conVal.val * 100) / 100; |
| 401 | if(decimalFixed) { |
| 402 | conVal.val = conVal.val.toFixed(decimalFixed); |
| 403 | } |
| 404 | return `${conVal.val} ${conVal.unit}`; |
| 405 | } |
| 406 | catch { |
| 407 | return ''; |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | export function compareSizeVals(val1, val2) { |
| 412 | const parseAndConvert = (val)=>{ |
no outgoing calls
no test coverage detected