/** * Waits until a provided function returns `true`, checking repeatedly at the defined interval. * Useful for polling asynchronous conditions. * * @param {() => boolean} getValue - A function that returns `true` when the condition is met. * @param {number} [checkInterval=100] - How often (in ms) to check the condition. * @returns {Promise} Resolves when the condition is met. * @throws {TypeError} If arguments are invalid. */ export declare const waitForTrue: (getValue: () => boolean, checkInterval?: number) => Promise; export type SingletonTaskResult = { /** * - The wrapped function that manages single execution. */ callback: (...args: A) => Promise; /** * - Returns the promise currently being executed or null if none is active. */ getActivePromise: () => Promise | null; /** * - Forces a reset of the active promise, allowing an immediate new execution. */ resetActivePromise: () => void; /** * - Returns true if the last execution (success or failure) has finished. */ isEnded: () => boolean; /** * - Returns true if the last execution resulted in an error. */ isFailed: () => boolean; /** * - Returns true if an execution is currently in progress. */ isLoading: () => boolean; }; /** * @template {any} T * @template {any[]} A * @typedef {Object} SingletonTaskResult * @property {(...args: A) => Promise} callback - The wrapped function that manages single execution. * @property {() => Promise | null} getActivePromise - Returns the promise currently being executed or null if none is active. * @property {() => void} resetActivePromise - Forces a reset of the active promise, allowing an immediate new execution. * @property {() => boolean} isEnded - Returns true if the last execution (success or failure) has finished. * @property {() => boolean} isFailed - Returns true if the last execution resulted in an error. * @property {() => boolean} isLoading - Returns true if an execution is currently in progress. */ /** * Creates a controller object that manages the execution state of an asynchronous function, * ensuring it only executes one instance at a time. * * If a task is already in progress, subsequent calls to the callback will return * the exact same promise as the first call, preventing redundant operations. * * @template {any} T * @template {any[]} A * @param {(...args: A) => Promise} baseFunction - The asynchronous function to be wrapped. * @param {boolean} [autoReset=true] - If true, the controller clears the active promise automatically * once the base function resolves or rejects. If false, the lock remains until `resetActivePromise` is called. * @returns {SingletonTaskResult} An object containing the execution controller and state monitors. * @throws {TypeError} If the provided baseFunction is not a function. */ export declare const createSingletonTask: (baseFunction: (...args: A) => Promise, autoReset?: boolean) => SingletonTaskResult; //# sourceMappingURL=promiseUtils.d.mts.map