taken from utils:::format.object_size

format_object_size(x, units = "b", ...)