```typescript
/** The index of target in a sorted array, or -1. */
export function binarySearch(items: readonly number[], target: number): number {
  /**
   * Find the index of `target` in a sorted array using binary search.
   *
   * If multiple values match `target`, returns the first occurrence's index.
   * Returns `-1` if no value is found.
   */
  let low = 0;
  let high = items.length - 1;
  while (low <= high) {
    const mid = Math.floor((low + high) / 2);
    if (items[mid] === target) {
      return mid;
    }
    if (items[mid] < target) {
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  return -1;
}
```