export class FormatHelper {
  public readableBytes(bytes: number | null) {
    if (!bytes && bytes !== 0) {
      return $localize`n/a`;
    }
    if (bytes === 0) {
      return '0 B';
    }
    const unit = Math.floor(Math.log(bytes) / Math.log(1024));
    const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
    const quantity = Number.parseFloat((bytes / Math.pow(1024, unit)).toFixed(2));
    return quantity + ' ' + sizes[unit];
  }

  public formatStatus(status: string): string {
    if (status.includes('_')) {
      status = status.split('_').join(' ');
    }

    return status;
  }
}
