/** * @file `memoizeAsync` — async-aware memoizer with the same LRU+TTL contract as * `memoize`, plus thundering-herd dedup. Concurrent callers join an in-flight * promise instead of starting fresh fetches, and the cache timestamp is * refreshed on resolution so a slow fn can't land a value that's already * "expired". */ import type { MemoizeOptions } from './types.js'; /** * Memoize an async function. Similar to memoize() but handles promises * properly. * * @example * import { memoizeAsync } from '@socketsecurity/lib/memo/async' * * const fetchUser = memoizeAsync( * async (id: string) => { * const response = await fetch(`/api/users/${id}`) * return response.json() * }, * { ttl: 300000, name: 'fetchUser' }, * ) * * await fetchUser('123') // Fetches from API * await fetchUser('123') // Returns cached result * * @param fn - Async function to memoize. * @param options - Memoization options. * * @returns Memoized version of the async function */ export declare function memoizeAsync(fn: (...args: Args) => Promise, options?: MemoizeOptions | undefined): (...args: Args) => Promise;