Skip to content

Instantly share code, notes, and snippets.

@oott123
Created July 25, 2015 04:20
Show Gist options
  • Save oott123/d36b40ada57582f0b490 to your computer and use it in GitHub Desktop.
Save oott123/d36b40ada57582f0b490 to your computer and use it in GitHub Desktop.
Node.js Harmony
node --harmony test.js
p1 callback
p3 callback
this is p1
"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