Created
July 11, 2023 11:47
-
-
Save codeepic/57c0442bf3e8a1b6a861d615347a3f30 to your computer and use it in GitHub Desktop.
Sleep
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
const sleep = (ms, data, useReject) => { | |
return new Promise((resolve, reject) => | |
setTimeout(() => { | |
if (useReject) { | |
reject(data); | |
} | |
return resolve(data); | |
}, ms) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment