```ts
/**
 * A fixed-capacity least-recently-used cache.
 */
export class LruCache<K, V> {
  private readonly capacity: number;
  private readonly map = new Map<K, V>();

  /**
   * Creates a new LRU cache with the given positive integer capacity.
   * @throws Error if capacity is not a positive integer.
   */
  constructor(capacity: number) {
    if (!Number.isInteger(capacity) || capacity <= 0) {
      throw new Error('Capacity must be a positive integer');
    }
    this.capacity = capacity;
  }

  /**
   * Retrieves the value for the given key, or undefined if not present.
   * If found, marks the entry as most