export const toSizeString = (bytes) => {
    if (!Number.isSafeInteger(bytes) || bytes < 0) {
        throw new TypeError('Number of bytes passed to toSizeString must be non-negative integer');
    }
    if (bytes >= 1024**4) {
        return (bytes / 1024**4).toFixed(2) + 'TB';
    }
    if (bytes >= 1024**3) {
        return (bytes / 1024**3).toFixed(2) + 'GB';
    }
    if (bytes >= 1024**2) {
        return (bytes / 1024**2).toFixed(2) + 'MB';
    }
    if (bytes >= 1024) {
        return (bytes / 1024).toFixed(2) + 'KB';
    }
    return bytes + 'B';
};
