rsxjs
Version:
Resilience Extensions for JS.
19 lines (18 loc) • 830 B
TypeScript
/**
* @file src/timeout/from-async.ts
* @copyright 2018-present Karim Alibhai. All rights reserved.
*/
import { AsyncFunction } from '../types';
import { TimeoutOptionsGiven } from './types';
/**
* Enforce a timeout over an existing promise.
* @param {Promise<T>} promise promise to enforce timeout over
* @param {TimeoutOptions} _options timeout options
* @returns {Promises<T>} resolves with the promise's value, or rejects with a timeout
*/
export declare function fromAsync<T>(cb: AsyncFunction<T>, options?: TimeoutOptionsGiven): AsyncFunction<T>;
/**
* Factory for timeouts to allow currying of timeout creation.
* @param {TimeoutOptionsGiven} options set of options to use when creating the timeout
*/
export declare function factory<T>(options: TimeoutOptionsGiven): (fn: AsyncFunction<T>) => AsyncFunction<T>;