matterbridge
Version:
Matterbridge plugin manager for Matter
43 lines • 2.42 kB
TypeScript
/**
* This file contains the wait, waiter and withTimeout functions.
*
* @file wait.ts
* @author Luca Liguori
* @date 2025-02-16
* @version 1.0.0
*
* Copyright 2025, 2026, 2027 Luca Liguori.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. *
*/
/**
* Asynchronous waiter function that resolves when the provided condition is met or rejects on timeout.
* @param {string} name - The name of the waiter.
* @param {() => boolean} check - A function that checks the condition. Should return a boolean.
* @param {boolean} [exitWithReject=false] - Optional. If true, the promise will be rejected on timeout. Default is false.
* @param {number} [resolveTimeout=5000] - Optional. The timeout duration in milliseconds. Default is 5000ms.
* @param {number} [resolveInterval=500] - Optional. The interval duration in milliseconds between condition checks. Default is 500ms.
* @param {boolean} [debug=false] - Optional. If true, debug messages will be logged to the console. Default is false.
* @returns {Promise<boolean>} A promise that resolves to true when the condition is met, or false if the timeout occurs.
*/
export declare function waiter(name: string, check: () => boolean, exitWithReject?: boolean, resolveTimeout?: number, resolveInterval?: number, debug?: boolean): Promise<boolean>;
/**
* Asynchronously waits for a specified amount of time.
* @param {number} timeout - The duration to wait in milliseconds. Default is 1000ms.
* @param {string} name - The name of the wait operation. Default is undefined.
* @param {boolean} debug - Whether to enable debug logging. Default is false.
* @returns {Promise<void>} A Promise that resolves after the specified timeout.
*/
export declare function wait(timeout?: number, name?: string, debug?: boolean): Promise<void>;
export declare function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T>;
//# sourceMappingURL=wait.d.ts.map