Created
January 29, 2019 05:58
-
-
Save mikermcneil/bd913197336390a4426dcf42afab9858 to your computer and use it in GitHub Desktop.
...as long as you properly handle things at the top level. (or otherwise just let https://npmjs.com/package/parley do it for you)
This file contains 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 hoHum() { | |
return 'ho hum'; | |
} | |
async function hiHo() { | |
return 'hi ho!'; | |
} | |
async function hoNo() { | |
throw new Error('ho... no!'); | |
} | |
async function hiHoNo() { | |
return await hiHo() + await hoNo(); | |
} | |
(async ()=>{ | |
await hoHum(); | |
await hiHo(); | |
await hiHoNo();//• | |
await hoHum(); | |
await hiHo(); | |
})().catch((err) => { | |
console.error('Failed with an error:', err); | |
}); |
(This gist is just an example to look at if you're worried about uncaught promise rejections and aren't sure if it's safe to use await
in this way)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yields