Created
February 7, 2025 03:50
-
-
Save xantiagoma/6ea2b38caef346cf600c95c31b6187ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function wait(ms: number): Promise<void>; | |
export async function wait<T>(ms: number, value: T): Promise<T>; | |
export async function wait<T>( | |
ms: number, | |
value?: T | undefined, | |
): Promise<T | undefined> { | |
return new Promise<T | undefined>((resolve) => | |
setTimeout( | |
() => (value === undefined ? resolve(undefined) : resolve(value)), | |
ms, | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment