@scayle/storefront-core
Version:
Collection of essential utilities to work with the Storefront API
21 lines (20 loc) • 770 B
TypeScript
/**
* Pauses execution for a specified number of milliseconds.
*
* @param ms The number of milliseconds to wait.
*
* @returns A Promise that resolves after the specified delay.
*/
export declare const wait: (ms: number) => Promise<void>;
/**
* Wraps a promise with a timeout. Rejects the promise if it doesn't resolve within the given time.
*
* @template T The type of the promise's resolved value.
* @param ms The timeout duration in milliseconds.
* @param promise The promise to wrap.
*
* @returns A new promise that resolves or rejects based on the original promise or the timeout.
*
* @throws {Error} If the promise times out. The error message will be "timeout".
*/
export declare const timeout: <T>(ms: number, promise: Promise<T>) => Promise<T>;