Created
August 28, 2019 23:06
-
-
Save Fishrock123/5d44f326a1db607781efb38af6409f29 to your computer and use it in GitHub Desktop.
Revisions
-
Fishrock123 created this gist
Aug 28, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ async function* f() { try { yield Promise.resolve(1) yield Promise.resolve(2) yield Promise.resolve(3) } finally { console.log('inside finally') // yield Promise.resolve(4) console.log('about to reject from finally') yield new Promise((res, rej) => { console.log('inside rejecting promise') rej('oh no') }) yield Promise.resolve(5) } } async function loop () { for await (const val of f()) { console.log(val) if (val === 2) break } } loop().catch(console.error)