{"version":3,"sources":["../src/doubly-linked-node.ts","../src/lru-cache.ts","../src/helpers/get-or-create-lru-cache.ts","../src/time-lru-cache.ts","../src/helpers/get-or-create-time-lru-cache.ts","../src/null-lru-cache.ts","../src/null-time-lru-cache.ts"],"names":["DoublyLinkedNode","key","LruCache","#maxSize","#touchOnHas","#onEviction","#cache","#head","#tail","params","maxSize","touchOnHas","onEviction","size","options","hasEntry","#moveToHead","value","data","newNode","#removeTail","valueOrFn","val","node","#removeNode","current","tailKey","getOrCreateLruCache","name","lruCacheParams","TimeLruCache","#ttl","defaultTTL","ttl","getOrCreateTimeLruCache","NullLruCache","_params","_key","_options","_value","NullTimeLruCache","_ttl"],"mappings":"aAEO,IAAMA,CAAAA,CAAN,KAAwE,CACpE,GAAA,CACT,IAAA,CAA8C,IAAA,CAC9C,IAAA,CAA8C,IAAA,CAC9C,WAAA,CAAYC,CAAAA,CAAW,CACrB,IAAA,CAAK,IAAMA,EACb,CACF,CAAA,CC2BO,IAAMC,CAAAA,CAAN,KAIP,CACEC,EAAAA,CACAC,GACAC,EAAAA,CAEAC,EAAAA,CACAC,EAAAA,CAA+C,IAAA,CAC/CC,EAAAA,CAA+C,IAAA,CAyB/C,WAAA,CAAYC,CAAAA,CAAsC,CAChD,GAAM,CAAE,OAAA,CAAAC,CAAAA,CAAS,UAAA,CAAAC,CAAAA,CAAa,KAAA,CAAO,UAAA,CAAAC,CAAW,CAAA,CAAIH,CAAAA,CACpD,GAAI,CAAC,MAAA,CAAO,aAAA,CAAcC,CAAO,GAAKA,CAAAA,CAAU,CAAA,CAC9C,MAAM,IAAI,SAAA,CAAU,iBAAiB,CAAA,CAEvC,IAAA,CAAKN,GAAcO,CAAAA,CACnB,IAAA,CAAKN,EAAAA,CAAcO,CAAAA,CACnB,IAAA,CAAKT,EAAAA,CAAWO,CAAAA,CAChB,IAAA,CAAKJ,GAAS,IAAI,IACpB,CAEA,IAAI,MAAA,EAA8B,CAChC,OAAO,CACL,OAAA,CAAS,IAAA,C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CACH,OAAO,OAAOpB,CAAAA,EAAc,UAAA,CACvBA,GAAsB,CACvBA,CACN,CAEA,IAAA,CAAKgB,CAAAA,CAAuB,CAE5B,CAEA,MAAA,CAAOA,EAAqB,CAC1B,OAAO,MACT,CAGA,EAAE,MAAA,CAAO,QAAQ,CAAA,EAAsC,CAAC,CAC1D","file":"index.cjs","sourcesContent":["import type { BaseCacheKeyTypes } from './types';\n\nexport class DoublyLinkedNode<TValue, TKey extends BaseCacheKeyTypes = string> {\n  readonly key: TKey;\n  prev: DoublyLinkedNode<TValue, TKey> | null = null;\n  next: DoublyLinkedNode<TValue, TKey> | null = null;\n  constructor(key: TKey) {\n    this.key = key;\n  }\n}\n","import { DoublyLinkedNode } from './doubly-linked-node';\nimport type { ILruCache } from './lru-cache.interface';\nimport type {\n  BaseCacheKeyTypes,\n  LruCacheHasOptions,\n  SupportedCacheValues,\n} from './types';\n\ntype LruCacheEntry<TValue, TKey extends BaseCacheKeyTypes = string> = {\n  value: TValue;\n  node: DoublyLinkedNode<TValue, TKey>;\n};\n\nexport type LruCacheParams<\n  TValue = unknown,\n  TKey extends BaseCacheKeyTypes = string,\n> = {\n  /**\n   * The maximum number of items that the cache can hold.\n   */\n  maxSize: number;\n  /**\n   * If true, the item will be marked as recently used when calling has.\n   * @default false\n   */\n  touchOnHas?: boolean;\n  /**\n   * Callback that will be called before an item is evicted from the cache.\n   * Useful for side effects or for items like object URLs that need explicit cleanup (revokeObjectURL).\n   */\n  onEviction?: (key: TKey, value: TValue) => void;\n};\n\n/**\n * Double linked list based lru cache that supports get in O(1)\n */\nexport class LruCache<\n  TValue extends SupportedCacheValues = SupportedCacheValues,\n  TKey extends BaseCacheKeyTypes = string,\n> implements ILruCache<TValue, TKey>\n{\n  #maxSize: number;\n  #touchOnHas: boolean;\n  #onEviction?: ((key: TKey, value: TValue) => void) | undefined;\n\n  #cache: Map<TKey, LruCacheEntry<TValue, TKey>>;\n  #head: DoublyLinkedNode<TValue, TKey> | null = null;\n  #tail: DoublyLinkedNode<TValue, TKey> | null = null;\n\n  /**\n   * Create a new LruCache instance.\n   *\n   * 👉 As an alternative to constructor, consider using the helper\n   * `getOrCreateLruCache` to ensure only one instance is created.\n   *\n   * @example\n   * ```typescript\n   * import { LruCache } from '@httpx/lru';\n   *\n   * const lru = new LruCache({ maxSize: 1000 });\n   *\n   * lru.set('🦄', ['cool', 'stuff']);\n   * if (lru.has('🦄')) {;\n   *  console.log(lru.get('🦄'));\n   *  // ['cool', 'stuff']\n   * }\n   * console.log(lru.size); // 1\n   * lru.delete('🦄');\n   * console.log(lru.size); // 0\n   * lru.clear();\n   * ```\n   */\n  constructor(params: LruCacheParams<TValue, TKey>) {\n    const { maxSize, touchOnHas = false, onEviction } = params;\n    if (!Number.isSafeInteger(maxSize) || maxSize < 1) {\n      throw new TypeError('Invalid maxSize');\n    }\n    this.#touchOnHas = touchOnHas;\n    this.#onEviction = onEviction;\n    this.#maxSize = maxSize;\n    this.#cache = new Map();\n  }\n\n  get params(): ILruCache['params'] {\n    return {\n      maxSize: this.#maxSize,\n    };\n  }\n\n  /**\n   * Return the current number of items in the cache\n   */\n  get size(): number {\n    return this.#cache.size;\n  }\n\n  clear(): number {\n    const size = this.#cache.size;\n    this.#cache.clear();\n    this.#head = this.#tail = null;\n    return size;\n  }\n\n  has(key: TKey, options?: LruCacheHasOptions): boolean {\n    const hasEntry = this.#cache.has(key);\n    if (hasEntry && (options?.touch ?? this.#touchOnHas)) {\n      this.#moveToHead(this.#cache.get(key)!.node);\n    }\n    return hasEntry;\n  }\n\n  set(key: TKey, value: TValue): boolean {\n    if (this.#cache.has(key)) {\n      const data = this.#cache.get(key)!;\n      data.value = value;\n      this.#moveToHead(data.node);\n      return false;\n    }\n\n    const newNode = new DoublyLinkedNode(key);\n    const data: LruCacheEntry<TValue, TKey> = { value, node: newNode };\n\n    this.#cache.set(key, data);\n    this.#moveToHead(newNode);\n\n    if (this.#cache.size > this.#maxSize) {\n      this.#removeTail();\n    }\n    return true;\n  }\n\n  get(key: TKey): TValue | undefined {\n    const data = this.#cache.get(key);\n    if (data === undefined) {\n      return;\n    }\n    this.#moveToHead(data.node);\n    return data.value;\n  }\n\n  getOrSet<T extends TValue>(key: TKey, valueOrFn: T | (() => T)): T {\n    const val = this.get(key);\n    if (val === undefined) {\n      const value =\n        typeof valueOrFn === 'function' ? (valueOrFn as () => T)() : valueOrFn;\n      this.set(key, value as unknown as TValue);\n      return value;\n    }\n    return val as unknown as T;\n  }\n\n  peek(key: TKey): TValue | undefined {\n    return this.#cache.get(key)?.value;\n  }\n\n  delete(key: TKey): boolean {\n    const node = this.#cache.get(key)?.node;\n    if (node === undefined) {\n      return false;\n    }\n    this.#removeNode(node);\n    return this.#cache.delete(key);\n  }\n\n  *[Symbol.iterator](): IterableIterator<[TKey, TValue]> {\n    let current = this.#tail;\n\n    while (current) {\n      const data = this.#cache.get(current.key)!;\n      yield [current.key, data.value];\n      current = current.prev;\n    }\n  }\n\n  #moveToHead(node: DoublyLinkedNode<TValue, TKey>): void {\n    if (node === this.#head) {\n      return;\n    }\n    this.#removeNode(node);\n    node.next = this.#head;\n    node.prev = null;\n    if (this.#head) {\n      this.#head.prev = node;\n    }\n    this.#head = node;\n    this.#tail ??= node;\n  }\n\n  #removeNode(node: DoublyLinkedNode<TValue, TKey>): void {\n    if (node.prev) {\n      node.prev.next = node.next;\n    }\n    if (node.next) {\n      node.next.prev = node.prev;\n    }\n    if (node === this.#head) {\n      this.#head = node.next;\n    }\n    if (node === this.#tail) {\n      this.#tail = node.prev;\n    }\n  }\n\n  #removeTail(): void {\n    if (this.#tail === null) {\n      return;\n    }\n    const tailKey = this.#tail.key;\n    this.#removeNode(this.#tail);\n    if (this.#onEviction) {\n      this.#onEviction(tailKey, this.#cache.get(tailKey)!.value);\n    }\n    this.#cache.delete(tailKey);\n  }\n}\n","import { LruCache, type LruCacheParams } from '../lru-cache';\nimport type { BaseCacheKeyTypes, SupportedCacheValues } from '../types';\n\ntype LruCacheSingleInstanceName = string;\n\ndeclare global {\n  // eslint-disable-next-line no-var\n  var __httpx_lru_cache_instances: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Map<LruCacheSingleInstanceName, LruCache<any, any>> | undefined;\n}\n\ntype Options = {\n  onCreate?: <\n    TValue extends SupportedCacheValues = SupportedCacheValues,\n    TKey extends BaseCacheKeyTypes = string,\n  >(\n    name: LruCacheSingleInstanceName,\n    params: LruCacheParams<TValue, TKey>\n  ) => void;\n};\n\n/**\n * Creates or retrieves a singleton LruCache instance by name\n * ensuring that only one instance exists for each unique name.\n *\n * This helper function relies on globalThis to store and retrieve\n * the instance.\n *\n * @example\n * ```typescript\n * import { getOrCreateLruCache } from '@httpx/lru';\n *\n * const lru = getOrCreateLruCache('main-cache', { maxSize: 500 });\n * ```\n *\n * @warning The same name must always be used with consistent TValue and TKey types.\n *          Calling this function with different type parameters for the same name will cause\n *          type safety violations and unexpected behavior.\n */\nexport const getOrCreateLruCache = <\n  TValue extends SupportedCacheValues = SupportedCacheValues,\n  TKey extends BaseCacheKeyTypes = string,\n>(\n  name: LruCacheSingleInstanceName,\n  lruCacheParams: LruCacheParams<TValue, TKey>,\n  options?: Options\n): LruCache<TValue, TKey> => {\n  globalThis.__httpx_lru_cache_instances ??= new Map<\n    LruCacheSingleInstanceName,\n    LruCache\n  >();\n  if (!globalThis.__httpx_lru_cache_instances.has(name)) {\n    if (options?.onCreate instanceof Function) {\n      options.onCreate(name, lruCacheParams);\n    }\n    globalThis.__httpx_lru_cache_instances.set(\n      name,\n      new LruCache<TValue, TKey>(lruCacheParams)\n    );\n  }\n  return globalThis.__httpx_lru_cache_instances.get(name)! as LruCache<\n    TValue,\n    TKey\n  >;\n};\n","import { DoublyLinkedNode } from './doubly-linked-node';\nimport type { LruCacheParams } from './lru-cache';\nimport type { ITimeLruCache } from './time-lru-cache.interface';\nimport type {\n  BaseCacheKeyTypes,\n  EpochTimeInMilliseconds,\n  LruCacheHasOptions,\n  Milliseconds,\n  SupportedCacheValues,\n} from './types';\n\ntype TimeLruCacheEntry<TValue, TKey extends BaseCacheKeyTypes = string> = {\n  value: TValue;\n  expiry: EpochTimeInMilliseconds;\n  node: DoublyLinkedNode<TValue, TKey>;\n};\n\nexport type TimeLruCacheParams<\n  TValue = unknown,\n  TKey extends BaseCacheKeyTypes = string,\n> = LruCacheParams<TValue, TKey> & {\n  /**\n   * Default time to live for each entry in milliseconds\n   */\n  defaultTTL: Milliseconds;\n};\n\n/**\n * Double linked list based lru cache that supports get in O(1) and time to live for each entry\n */\nexport class TimeLruCache<\n  TValue extends SupportedCacheValues = SupportedCacheValues,\n  TKey extends BaseCacheKeyTypes = string,\n> implements ITimeLruCache<TValue, TKey>\n{\n  #maxSize: number;\n  #touchOnHas: boolean;\n\n  #ttl: Milliseconds;\n\n  #onEviction?: ((key: TKey, value: TValue) => void) | undefined;\n\n  #cache: Map<TKey, TimeLruCacheEntry<TValue, TKey>>;\n  #head: DoublyLinkedNode<TValue, TKey> | null = null;\n  #tail: DoublyLinkedNode<TValue, TKey> | null = null;\n\n  /**\n   * Create a new LruCache instance\n   *\n   * 👉 As an alternative to constructor, consider using the helper\n   * `getOrCreateTimeLruCache` to ensure only one instance is created.\n   *\n   * @example\n   * ```typescript\n   * import { TimeLruCache } from '@httpx/lru';\n   *\n   * const THIRTY_SECONDS_IN_MILLIS = 30_000\n   *\n   * const lru = new TimeLruCache({ maxSize: 1000, defaultTTL: THIRTY_SECONDS_IN_MILLIS});\n   * lru.set('🦄', ['cool', 'stuff'], THIRTY_SECONDS_IN_MILLIS);\n   * if (lru.has('🦄')) {;\n   *  console.log(lru.get('🦄'));\n   *  // ['cool', 'stuff']\n   * }\n   * console.log(lru.size); // 1\n   * lru.delete('🦄');\n   * console.log(lru.size); // 0\n   * lru.clear();\n   * ```\n   */\n  constructor(params: TimeLruCacheParams<TValue, TKey>) {\n    const { maxSize, touchOnHas = false, onEviction, defaultTTL } = params;\n    if (!Number.isSafeInteger(maxSize) || maxSize < 1) {\n      throw new TypeError('Invalid maxSize');\n    }\n    if (!Number.isSafeInteger(defaultTTL) || defaultTTL < 1) {\n      throw new TypeError('Invalid ttl');\n    }\n\n    this.#touchOnHas = touchOnHas;\n    this.#onEviction = onEviction;\n    this.#maxSize = maxSize;\n    this.#ttl = defaultTTL;\n    this.#cache = new Map();\n  }\n\n  /**\n   * Return the current size of the cache\n   */\n  get params(): ITimeLruCache['params'] {\n    return {\n      maxSize: this.#maxSize,\n      defaultTTL: this.#ttl,\n    };\n  }\n\n  /**\n   * Return the current number of entries in the cache\n   */\n  get size(): number {\n    return this.#cache.size;\n  }\n\n  clear(): number {\n    const size = this.#cache.size;\n    this.#cache.clear();\n    this.#head = this.#tail = null;\n    return size;\n  }\n\n  has(key: TKey, options?: LruCacheHasOptions): boolean {\n    const value = this.#cache.get(key);\n    const hasEntry = value !== undefined;\n    const hasExpired = hasEntry && value.expiry < Date.now();\n\n    if (hasExpired) {\n      if (this.#onEviction) {\n        this.#onEviction(key, this.#cache.get(key)!.value);\n      }\n      this.#removeNode(value.node);\n      return false;\n    }\n\n    if (hasEntry && (options?.touch ?? this.#touchOnHas)) {\n      this.#moveToHead(this.#cache.get(key)!.node);\n    }\n    return hasEntry;\n  }\n\n  set(key: TKey, value: TValue, ttl?: Milliseconds): boolean {\n    if (this.#cache.has(key)) {\n      const data = this.#cache.get(key)!;\n      data.value = value;\n      data.expiry = Date.now() + (ttl ?? this.#ttl);\n      this.#moveToHead(data.node);\n      return false;\n    }\n\n    const newNode = new DoublyLinkedNode(key);\n    const data: TimeLruCacheEntry<TValue, TKey> = {\n      value,\n      expiry: Date.now() + (ttl ?? this.#ttl),\n      node: newNode,\n    };\n\n    this.#cache.set(key, data);\n    this.#moveToHead(newNode);\n\n    if (this.#cache.size > this.#maxSize) {\n      this.#removeTail();\n    }\n    return true;\n  }\n\n  get(key: TKey): TValue | undefined {\n    const data = this.#cache.get(key);\n    if (data === undefined) {\n      return;\n    }\n    if (data.expiry < Date.now()) {\n      if (this.#onEviction) {\n        this.#onEviction(key, data.value);\n      }\n      this.#removeNode(data.node);\n      return;\n    }\n\n    this.#moveToHead(data.node);\n\n    return data.value;\n  }\n\n  getOrSet<T extends TValue>(\n    key: TKey,\n    valueOrFn: T | (() => T),\n    ttl?: Milliseconds\n  ): T {\n    const val = this.get(key);\n    if (val === undefined) {\n      const value =\n        typeof valueOrFn === 'function' ? (valueOrFn as () => T)() : valueOrFn;\n      this.set(key, value as unknown as TValue, ttl);\n      return value;\n    }\n    return val as unknown as T;\n  }\n\n  peek(key: TKey): TValue | undefined {\n    const val = this.#cache.get(key);\n    if (val === undefined) {\n      return;\n    }\n    return val.expiry < Date.now() ? undefined : val.value;\n  }\n\n  delete(key: TKey): boolean {\n    const node = this.#cache.get(key)?.node;\n    if (node === undefined) {\n      return false;\n    }\n    this.#removeNode(node);\n    return this.#cache.delete(key);\n  }\n\n  /**\n   * Iterate over the cache from the least recently used to the most recently used.\n   *\n   * ```typescript\n   * const lru = new LruCache({ maxSize: 2 });\n   * lru.set('key1', 'value1');\n   * lru.set('key2', 'value2');\n   * lru.set('key3', 'value3');\n   * // trigger a get to move key2 to the head\n   * lru.get('key2');\n   * const results = [];\n   * // iterate over the cache entries\n   * for (const [key, value] of lru) {\n   *   results.push([key, value]);\n   * }\n   * expect(results).toStrictEqual([\n   *    ['key3', 'value3'], // Least recently used\n   *    ['key2', 'value2'], // Most recently used\n   * ]);\n   * ```\n   */\n  *[Symbol.iterator](): IterableIterator<[TKey, TValue]> {\n    let current = this.#tail;\n\n    while (current) {\n      const data = this.#cache.get(current.key)!;\n      yield [current.key, data.value];\n      current = current.prev;\n    }\n  }\n\n  #moveToHead(node: DoublyLinkedNode<TValue, TKey>): void {\n    if (node === this.#head) {\n      return;\n    }\n    this.#removeNode(node);\n    node.next = this.#head;\n    node.prev = null;\n    if (this.#head) {\n      this.#head.prev = node;\n    }\n    this.#head = node;\n    this.#tail ??= node;\n  }\n\n  #removeNode(node: DoublyLinkedNode<TValue, TKey>): void {\n    if (node.prev) {\n      node.prev.next = node.next;\n    }\n    if (node.next) {\n      node.next.prev = node.prev;\n    }\n    if (node === this.#head) {\n      this.#head = node.next;\n    }\n    if (node === this.#tail) {\n      this.#tail = node.prev;\n    }\n  }\n\n  #removeTail(): void {\n    if (this.#tail === null) {\n      return;\n    }\n    const tailKey = this.#tail.key;\n    this.#removeNode(this.#tail);\n    if (this.#onEviction) {\n      this.#onEviction(tailKey, this.#cache.get(tailKey)!.value);\n    }\n    this.#cache.delete(tailKey);\n  }\n}\n","import { TimeLruCache, type TimeLruCacheParams } from '../time-lru-cache';\nimport type { BaseCacheKeyTypes, SupportedCacheValues } from '../types';\n\ntype TimeLruCacheSingleInstanceName = string;\n\ndeclare global {\n  // eslint-disable-next-line no-var\n  var __httpx_time_lru_cache_instances: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Map<TimeLruCacheSingleInstanceName, TimeLruCache<any, any>> | undefined;\n}\n\ntype Options = {\n  onCreate?: <\n    TValue extends SupportedCacheValues = SupportedCacheValues,\n    TKey extends BaseCacheKeyTypes = string,\n  >(\n    name: TimeLruCacheSingleInstanceName,\n    params: TimeLruCacheParams<TValue, TKey>\n  ) => void;\n};\n\n/**\n * Creates or retrieves a singleton TimeLruCache instance by name\n * ensuring that only one instance exists for each unique name.\n *\n * This helper function relies on globalThis to store and retrieve\n * the instance.\n *\n * @example\n * ```typescript\n * import { getOrCreateTimeLruCache } from '@httpx/lru';\n *\n * const ttlLru = getOrCreateTimeLruCache('main-cache', { maxSize: 500, defaultTTL: 60000 });\n * ```\n *\n * @warning The same name must always be used with consistent TValue and TKey types.\n *          Calling this function with different type parameters for the same name will cause\n *          type safety violations and unexpected behavior.\n */\nexport const getOrCreateTimeLruCache = <\n  TValue extends SupportedCacheValues = SupportedCacheValues,\n  TKey extends BaseCacheKeyTypes = string,\n>(\n  name: TimeLruCacheSingleInstanceName,\n  lruCacheParams: TimeLruCacheParams<TValue, TKey>,\n  options?: Options\n): TimeLruCache<TValue, TKey> => {\n  globalThis.__httpx_time_lru_cache_instances ??= new Map<\n    TimeLruCacheSingleInstanceName,\n    TimeLruCache\n  >();\n  if (!globalThis.__httpx_time_lru_cache_instances.has(name)) {\n    if (options?.onCreate instanceof Function) {\n      options.onCreate(name, lruCacheParams);\n    }\n    globalThis.__httpx_time_lru_cache_instances.set(\n      name,\n      new TimeLruCache<TValue, TKey>(lruCacheParams)\n    );\n  }\n  return globalThis.__httpx_time_lru_cache_instances.get(name)! as TimeLruCache<\n    TValue,\n    TKey\n  >;\n};\n","import type { LruCacheParams } from './lru-cache';\nimport type { ILruCache } from './lru-cache.interface';\nimport type {\n  BaseCacheKeyTypes,\n  LruCacheHasOptions,\n  SupportedCacheValues,\n} from './types';\n\nexport class NullLruCache<\n  TValue extends SupportedCacheValues = SupportedCacheValues,\n  TKey extends BaseCacheKeyTypes = string,\n> implements ILruCache<TValue, TKey>\n{\n  /**\n   * Create a new NullLruCache (does cache nothing)\n   *\n   * @example\n   * ```typescript\n   * import { NullLruCache } from '@httpx/lru';\n   *\n   * const lru = new NullLruCache({ maxSize: 1000 });\n   * ```\n   */\n  // eslint-disable-next-line @typescript-eslint/no-empty-function\n  constructor(_params: LruCacheParams<TValue, TKey>) {}\n\n  readonly size = 0;\n  readonly params = {\n    maxSize: 0,\n  };\n\n  clear(): number {\n    return 0;\n  }\n\n  has(_key: TKey, _options?: LruCacheHasOptions): boolean {\n    return false;\n  }\n\n  set(_key: TKey, _value: TValue): boolean {\n    return false;\n  }\n\n  get(_key: TKey): undefined {\n    return undefined;\n  }\n\n  getOrSet<T extends TValue>(_key: TKey, valueOrFn: T | (() => T)): T {\n    return typeof valueOrFn === 'function'\n      ? (valueOrFn as () => T)()\n      : valueOrFn;\n  }\n\n  peek(_key: TKey): undefined {\n    return undefined;\n  }\n\n  delete(_key: TKey): boolean {\n    return false;\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-empty-function\n  *[Symbol.iterator](): IterableIterator<[TKey, TValue]> {}\n}\n","import type { TimeLruCacheParams } from './time-lru-cache';\nimport type { ITimeLruCache } from './time-lru-cache.interface';\nimport type {\n  BaseCacheKeyTypes,\n  LruCacheHasOptions,\n  Milliseconds,\n  SupportedCacheValues,\n} from './types';\n\nexport class NullTimeLruCache<\n  TValue extends SupportedCacheValues = SupportedCacheValues,\n  TKey extends BaseCacheKeyTypes = string,\n> implements ITimeLruCache<TValue, TKey>\n{\n  /**\n   * Create a new NullTimeLruCache (does cache nothing)\n   *\n   * @example\n   * ```typescript\n   * import { NullTimeLruCache } from '@httpx/lru';\n   *\n   * const lru = new NullTimeLruCache({ maxSize: 1000 });\n   * ```\n   */\n  // eslint-disable-next-line @typescript-eslint/no-empty-function\n  constructor(_params: TimeLruCacheParams<TValue, TKey>) {}\n\n  readonly size = 0;\n  readonly params = {\n    maxSize: 0,\n    defaultTTL: 0,\n  };\n\n  clear(): number {\n    return 0;\n  }\n\n  has(_key: TKey, _options?: LruCacheHasOptions): boolean {\n    return false;\n  }\n\n  set(_key: TKey, _value: TValue, _ttl?: Milliseconds): boolean {\n    return false;\n  }\n\n  get(_key: TKey): undefined {\n    return undefined;\n  }\n\n  getOrSet<T = TValue>(\n    _key: TKey,\n    valueOrFn: T | (() => T),\n    _ttl?: Milliseconds\n  ): T {\n    return typeof valueOrFn === 'function'\n      ? (valueOrFn as () => T)()\n      : valueOrFn;\n  }\n\n  peek(_key: TKey): undefined {\n    return undefined;\n  }\n\n  delete(_key: TKey): boolean {\n    return false;\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-empty-function\n  *[Symbol.iterator](): IterableIterator<[TKey, TValue]> {}\n}\n"]}