/** * Utilities for safe AbortSignal listener management to prevent memory leaks */ /** * Safely adds a one-time abort listener that automatically cleans up after firing * @param signal - The AbortSignal to listen to * @param callback - The function to call when aborted * @returns A cleanup function to manually remove the listener if needed */ export declare function addOnceAbortListener(signal: AbortSignal, callback: () => void): () => void; /** * Creates a Promise that rejects when the AbortSignal is aborted * Uses once-only listener to prevent accumulation * @param signal - The AbortSignal to listen to * @param errorMessage - Optional custom error message * @returns Promise that rejects on abort */ export declare function createAbortPromise(signal: AbortSignal, errorMessage?: string): Promise; /** * Wrapper that manages abort signal listeners with automatic cleanup * @param signal - The AbortSignal to manage * @param operation - Function that sets up listeners and returns cleanup * @returns Promise that resolves with the operation result */ export declare function withAbortCleanup(signal: AbortSignal, operation: (signal: AbortSignal) => Promise): Promise; /** * Consolidates multiple abort listeners into a single listener * Useful when multiple handlers need to respond to the same abort signal * @param signal - The AbortSignal to listen to * @param callbacks - Array of functions to call when aborted * @returns Cleanup function to remove the consolidated listener */ export declare function addConsolidatedAbortListener(signal: AbortSignal, callbacks: (() => void)[]): () => void;