```ts
export function sizeUnit(bytesCount: number): string {
  if (bytesCount < 1024) {
    return "B";
  }
  if (bytesCount < 1024 * 1024) {
    return "KB";
  }
  return "MB";
}

/** A byte count written in whole units. */
export function sizeText(bytesCount: number): string {
  if (bytesCount < 0) {
    throw new Error("a byte count cannot be negative");
  }
  const unit = sizeUnit(bytesCount);
  if (unit === "B") {
    return String(bytesCount) + " B";
  }
  if (unit === "KB") {
    return Math.floor(bytesCount / 1024).toString() + " KB";
  }
  return Math.floor(bytesCount / (1024 * 1024)).toString() + " MB";
}
```