```ts
/** The index of target in a sorted array, or -1. */
export function binarySearch(items: readonly number[], target: number): number {
  let low = 0;
  let high = items.length - 1; // Changed to -1 to exclude upper bound
  while (low <= high) { // Changed to <= for inclusive bounds
    const mid = Math.floor((low + high) / 2);
    if (items[mid] === target) {
      return mid;
    }
    if (items[mid] < target) {
      low = mid + 1;
    } else {
      high = mid - 1; // Changed to prevent exclusion of upper bound
    }
  }
  return items.includes(target) ? mid : -1; // Added condition for duplicates and absent value
}
```