Skip to content

Instantly share code, notes, and snippets.

@zvakanaka
Created May 12, 2025 22:57
Show Gist options
  • Save zvakanaka/f01f02f703dc64ef87946b1ac908dda7 to your computer and use it in GitHub Desktop.
Save zvakanaka/f01f02f703dc64ef87946b1ac908dda7 to your computer and use it in GitHub Desktop.
/*
* Waits for a specified amount of time before resolving.
* @param {number} waitMs - The amount of time to wait in milliseconds
* @returns {Promise<void>} - A promise that resolves after the specified amount of time
*/
const timeout = (waitMs) => {
return new Promise((resolve) => {
const timer = setTimeout(() => {
clearTimeout(timer)
resolve()
}, waitMs)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment