UNPKG

@darkobits/sleep

Version:
25 lines (24 loc) 971 B
/** * Coerces Errors to `never`. */ export type FinalValue<V> = V extends Error ? never : V; /** * Returns a Promise that settles after the provided `delay`, which may be * expressed as a number (of milliseconds) or as a string ('10 seconds'). * * If an instance of `Error` was passed as the second argument, the Promise will * reject with the error. If any other value was provided, the Promise will * resolve with the value. */ declare function sleep<V = any>(delay: string | number, value?: V): Promise<FinalValue<V>>; declare namespace sleep { var sync: <T = any>(delay: string | number, value?: T | undefined) => FinalValue<T>; } export default sleep; /** * @deprecated Pass an Error to `sleep` to cause a rejection. * * Returns a Promise that rejects after the provided delay. Delay may be * expressed as a number (of milliseconds) or as a string. */ export declare function rejectAfter<T = any>(delay: string | number, value?: T): Promise<void>;