mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-27 00:36:52 -06:00
34 lines
838 B
JavaScript
34 lines
838 B
JavaScript
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
define([],
|
|
function () {
|
|
var sizePrettify = function (rawSize) {
|
|
var size = Math.abs(rawSize),
|
|
limit = 10 * 1024,
|
|
limit2 = limit - 1,
|
|
cnt = 0,
|
|
sizeUnits = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'];
|
|
|
|
if (size < limit)
|
|
return size + ' ' + sizeUnits[cnt]; // return in bytes format
|
|
else
|
|
{
|
|
do {
|
|
size = size / 1024;
|
|
cnt += 1;
|
|
} while (size > limit2);
|
|
|
|
return Math.round(size) + ' ' + sizeUnits[cnt];
|
|
}
|
|
};
|
|
|
|
return sizePrettify;
|
|
});
|