MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / toPrettySize

Function toPrettySize

web/pgadmin/static/js/utils.js:393–409  ·  view source on GitHub ↗
(rawSize, from='B', decimalFixed=null)

Source from the content-addressed store, hash-verified

391}
392
393export 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
411export function compareSizeVals(val1, val2) {
412 const parseAndConvert = (val)=>{

Callers 10

DownloadUtils.jsFile · 0.90
getColumnFunction · 0.90
GraphsWrapperFunction · 0.90
PGDReplicationFunction · 0.90
MemoryFunction · 0.90
CpuDetailsFunction · 0.90
StorageFunction · 0.90
StorageWrapperFunction · 0.90
getValueFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected