```typescript
/** Count the hits a key stream scores on a direct-mapped cache. */

export function slotHits(keys: number[], slots: number): number {
  if (!Number.isInteger(slots) || slots <= 0) {
    throw new Error("Slot count must be a positive integer.");
  }

  const held: (number | null)[] = new Array(slots).fill(null);
  let hits = 0;

  for (const key of keys) {
    if (!Number.isInteger(key)) {
      throw new Error("Key must be an integer.");
    }

    const slot = Math.abs(key) % slots;
    if (held[slot] === key) {
      hits++;
    } else {
      held[slot] = key;
    }
  }

  return hits;
}
```