Created
July 24, 2019 19:48
-
-
Save nijotz/7f913c8d7ce5f2d965b7d282080ea272 to your computer and use it in GitHub Desktop.
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
function sleepReject(time, msg) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => reject(msg || 'reject'), time); | |
}); | |
} | |
async function test() { | |
try { | |
let valuePromises1 = [1000, 2000, 3000].map(x => sleepReject(x)); | |
let values1 = await Promise.all(valuePromises1); | |
console.log(values1); | |
} catch (error) { | |
console.log(error); | |
} | |
} | |
test() | |
// node promises.js | |
// "reject" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment