Last active
January 21, 2019 15:03
-
-
Save rayets123/a5ed8ca195250dc8220c46744ece1faf to your computer and use it in GitHub Desktop.
Revisions
-
rayets123 revised this gist
Jan 21, 2019 . 1 changed file with 2 additions and 4 deletions.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 @@ -1,16 +1,14 @@ async function bar() { await new Promise(r=> setTimeout(r, 1000)) console.log('bar'); } async function bam() { await new Promise((ignore, reject)=> setTimeout(reject, 2000)) .catch(()=> { console.log('bam errored'); throw 'bam'; }); } async function bat() { await new Promise(r=> setTimeout(r, 3000)) console.log('bat'); } function handleRejection(p) { -
rayets123 created this gist
Jan 21, 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 bar() { await new Promise(r=> setTimeout(r, 1000)) .then(()=> console.log('bar')) .then(()=> 'bar result'); } async function bam() { await new Promise((ignore, reject)=> setTimeout(reject, 2000)) .catch(()=> { console.log('bam errored'); throw 'bam'; }); } async function bat() { await new Promise(r=> setTimeout(r, 3000)) .then(()=> console.log('bat')) .then(()=> 'bat result'); } function handleRejection(p) { return p.catch(err=> ({ error: err })); } async function foo(arr) { console.log('foo'); return await Promise.all([bar(), bam(), bat()].map(handleRejection)); } foo().then(results=> console.log('done', results));