/** * @param unref defaults to `false`, when true, call `unref()` on the timer. * can not set to `true` on other platform (will throw "unref is not function" error). * @returns promise reject with TimeoutError after specific time */ export declare function timeout(ms: number, error?: string, boundary?: Function, unref?: boolean): Promise; /** * @param unref defaults to `false`, when true, call `unref()` on the timer. * can not set to `true` on other platform. * @returns promise resolve after specific time */ export declare function sleep(ms: number, unref?: boolean): Promise; export declare function raceTimeout(ms: number, p: PromiseLike): Promise; export declare function raceTimeout(ms: number, message: string, p: PromiseLike): Promise; /** * 注意: 多次重试会并行,比如第一次重试过程中,首次发送的请求突然成功了(或失败了),那么会直接返回成功结果,第一次重试的请求即使也成功了,也会被丢弃。 * 因此建议重试的请求本身具有幂等性(如各种数据下载请求),或者自身无超时机制(如简单的锁)。 */ export declare function raceTimeoutWithRetry(ms: number, retry: number, factory: () => Promise): Promise; //# sourceMappingURL=timeout.d.ts.map