-
-
Save parkerproject/438272d6d7bf93f8b65a415461ca25c2 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
| async function doSomething() { | |
| await timeout(2000); | |
| } | |
| function timeout(ms) { | |
| return new Promise((res,rej) => setTimeout(rej,ms)); | |
| } | |
| Promise.race([ | |
| doSomething(), | |
| timeout(1000) | |
| ]) | |
| .then( () => console.log('success') , () => console.log('failure') ); | |
| timeout(3000).catch( () => { | |
| console.log(process._getActiveHandles()); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment