2023-08-23 13:39:12 -04:00
|
|
|
/**
|
2024-11-15 11:44:18 -05:00
|
|
|
* Waits for a number of milliseconds.
|
|
|
|
|
*
|
2023-08-23 13:39:12 -04:00
|
|
|
* @param milliseconds The number of milliseconds to wait.
|
2024-11-15 11:44:18 -05:00
|
|
|
* @returns Resolves with 'done!' after the wait is over.
|
2023-08-23 13:39:12 -04:00
|
|
|
*/
|
2019-12-06 14:22:35 -05:00
|
|
|
export async function wait(milliseconds: number): Promise<string> {
|
2024-11-15 11:44:18 -05:00
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
if (isNaN(milliseconds)) throw new Error('milliseconds is not a number')
|
2019-09-21 08:56:30 -04:00
|
|
|
|
2019-12-06 14:22:35 -05:00
|
|
|
setTimeout(() => resolve('done!'), milliseconds)
|
|
|
|
|
})
|
2019-09-21 08:56:30 -04:00
|
|
|
}
|