@esfx/async-delay Package
The @esfx/async-delay
package provides the delay(msec) function.
Installation
npm i @esfx/async-delay
Usage
import { delay } from "@esfx/async-delay";
async function doSomeAction() {
// wait 10 seconds
await delay(10 * 1000);
}
Functions
delay(msec)
Waits the specified number of milliseconds before resolving.
Declaration
export declare function delay(msec: number): Promise<void>;
Parameters
Returns
Promise<void>
delay(msec, value)
Waits the specified number of milliseconds before resolving with the provided value.
Declaration
export declare function delay<T>(msec: number, value: PromiseLike<T> | Exclude<T, Cancelable>): Promise<T>;
Type Parameters
- T
Parameters
- value
- PromiseLike<T> | Exclude<T, Cancelable>
An optional value for the resulting Promise. May not be a Cancelable — if you intend to resolve with a Cancelable you must use a different overload.
Returns
Promise<T>
delay(cancelable, msec)
Waits the specified number of milliseconds before resolving.
Declaration
export declare function delay(cancelable: Cancelable | null | undefined, msec: number): Promise<void>;
Parameters
Returns
Promise<void>
delay(cancelable, msec, value)
Waits the specified number of milliseconds before resolving with the provided value.
Declaration
export declare function delay<T>(cancelable: Cancelable | null | undefined, msec: number, value: T | PromiseLike<T>): Promise<T>;
Type Parameters
- T
Parameters
Returns
Promise<T>