/**
 * Options for memoization behavior.
 */
type MemoizeOptions<Args extends unknown[], _Result = unknown> = {
    /** Custom cache key generator (defaults to JSON.stringify) */
    keyGen?: (...args: Args) => string;
    /** Maximum cache size (LRU eviction when exceeded) */
    maxSize?: number;
    /** TTL in milliseconds (cache entries expire after this time) */
    ttl?: number;
    /** Cache name for debugging */
    name?: string;
    /** Weak cache for object keys (enables GC) */
    weak?: boolean;
    /** Custom equality check for cache hits */
    equals?: (a: Args, b: Args) => boolean;
};
/**
 * Memoize a function with configurable caching behavior.
 * Caches function results to avoid repeated computation.
 *
 * @param fn - Function to memoize
 * @param options - Memoization options
 * @returns Memoized version of the function
 *
 * @example
 * import { memoize } from '@socketsecurity/lib/memoization'
 *
 * const expensiveOperation = memoize((n: number) => {
 *   // Heavy computation
 *   return Array(n).fill(0).reduce((a, _, i) => a + i, 0)
 * }, { maxSize: 100, ttl: 60000, name: 'sum' })
 *
 * expensiveOperation(1000) // Computed
 * expensiveOperation(1000) // Cached
 */
export declare function memoize<Args extends unknown[], Result>(fn: (...args: Args) => Result, options?: MemoizeOptions<Args, Result>): (...args: Args) => Result;
/**
 * Memoize an async function.
 * Similar to memoize() but handles promises properly.
 *
 * @param fn - Async function to memoize
 * @param options - Memoization options
 * @returns Memoized version of the async function
 *
 * @example
 * import { memoizeAsync } from '@socketsecurity/lib/memoization'
 *
 * 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
 */
export declare function memoizeAsync<Args extends unknown[], Result>(fn: (...args: Args) => Promise<Result>, options?: MemoizeOptions<Args, Result>): (...args: Args) => Promise<Result>;
/**
 * Create a memoized version of a method.
 * Preserves 'this' context for class methods.
 *
 * @param target - Object containing the method
 * @param propertyKey - Method name
 * @param descriptor - Property descriptor
 * @returns Modified descriptor with memoized method
 *
 * @example
 * import { Memoize } from '@socketsecurity/lib/memoization'
 *
 * class Calculator {
 *   @Memoize()
 *   fibonacci(n: number): number {
 *     if (n <= 1) return n
 *     return this.fibonacci(n - 1) + this.fibonacci(n - 2)
 *   }
 * }
 */
export declare function Memoize(options?: MemoizeOptions<unknown[], unknown>): (_target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
/**
 * Clear all memoization caches.
 * Useful for testing or when you need to force recomputation.
 */
export declare function clearAllMemoizationCaches(): void;
/**
 * Memoize with WeakMap for object keys.
 * Allows garbage collection when objects are no longer referenced.
 * Only works when first argument is an object.
 *
 * @param fn - Function to memoize
 * @returns Memoized version using WeakMap
 *
 * @example
 * import { memoizeWeak } from '@socketsecurity/lib/memoization'
 *
 * const processConfig = memoizeWeak((config: Config) => {
 *   return expensiveTransform(config)
 * })
 *
 * processConfig(config1) // Computed
 * processConfig(config1) // Cached
 * // When config1 is no longer referenced, cache entry is GC'd
 */
export declare function memoizeWeak<K extends object, Result>(fn: (key: K) => Result): (key: K) => Result;
/**
 * Simple once() implementation - caches single result forever.
 * Useful for initialization functions that should only run once.
 *
 * @param fn - Function to run once
 * @returns Memoized version that only executes once
 *
 * @example
 * import { once } from '@socketsecurity/lib/memoization'
 *
 * const initialize = once(() => {
 *   console.log('Initializing…')
 *   return loadConfig()
 * })
 *
 * initialize() // Logs "Initializing…" and returns config
 * initialize() // Returns cached config (no log)
 */
export declare function once<Result>(fn: () => Result): () => Result;
/**
 * Create a debounced memoized function.
 * Combines memoization with debouncing for expensive operations.
 *
 * @param fn - Function to memoize and debounce
 * @param wait - Debounce wait time in milliseconds
 * @param options - Memoization options
 * @returns Debounced memoized function
 *
 * @example
 * import { memoizeDebounced } from '@socketsecurity/lib/memoization'
 *
 * const search = memoizeDebounced(
 *   (query: string) => performSearch(query),
 *   300,
 *   { name: 'search' }
 * )
 */
export declare function memoizeDebounced<Args extends unknown[], Result>(fn: (...args: Args) => Result, wait: number, options?: MemoizeOptions<Args, Result>): (...args: Args) => Result;
export {};
