```
export function sizeUnit(bytesCount: number): string {
  if (bytesCount < 1024) {
    return "B";
  }
  if (bytesCount >= 1024 && bytesCount < 1024 * 1024) {
    return "KB";
  } else if (bytesCount >= 1024 * 1024 && bytesCount <= 1024 * 1024 * 1000) {
    return "MB";
  }
  throw new Error("a byte count cannot be negative");
}

/** 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";
  } else if (unit === "KB") {
    return String(Math.floor(bytesCount / 1024)) + " KB";
  } else if (unit === "MB") {
    return String(Math.floor(bytesCount / (1024 * 1000))) + " MB";
  }
}
```