Created
July 25, 2015 04:20
-
-
Save oott123/d36b40ada57582f0b490 to your computer and use it in GitHub Desktop.
Node.js Harmony
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
node --harmony test.js | |
p1 callback | |
p3 callback | |
this is p1 |
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
"use strict"; | |
var p1 = new Promise((resolve, reject) => { | |
console.log("p1 callback"); | |
resolve("this is p1"); | |
}); | |
var p2 = Promise.reject(2); | |
var p3 = new Promise((resolve, reject) => { | |
console.log("p3 callback"); | |
resolve("this is p3"); | |
}); | |
var p4 = Promise.race([p1, p2, p3]); | |
p4 | |
.then( | |
(value) => { | |
console.log(value); | |
}, | |
(error) => { | |
console.log(error); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment