import numeral from 'numeral';
const unitsList = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'];
export const b2ValueUnit = (val: number, fmt = '0,0.00') => {
let unit = 'B';
let value = numeral(val);
unitsList.forEach((item) => {
if (value.value() >= 1024) {
value = value.divide(1024);
unit = item;
}
});
return [numeral(value).format(fmt), unit];
};