Skip to content

Instantly share code, notes, and snippets.

@imgnx
Last active January 9, 2025 19:13
Show Gist options
  • Save imgnx/32b739c66c7c0c8ce8a4106591763adb to your computer and use it in GitHub Desktop.
Save imgnx/32b739c66c7c0c8ce8a4106591763adb to your computer and use it in GitHub Desktop.
// sleep.js
const sleep = async (time = 1000) =>
{
return await new Promise((res) => {
setTimeout(() => {
res();
}, time);
});
};
export default sleep;
/**
* Usage:
* import sleep from "sleep"
* (async () => {
*. // Todo: Wait 5 seconds...
* sleep(5000);
* // ... and resume.
* })()
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment