Last active
August 29, 2015 14:03
-
-
Save coolaj86/1881e0e37780e1e103d4 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
// node --version v0.11.13 | |
// node --harmony | |
// | |
// Composition FAIL | |
// | |
var p1 | |
; | |
p1 = new Promise(function (resolve, reject) { | |
var p2 | |
; | |
p2 = new Promise(function (resolve, reject) { | |
resolve("Hey"); | |
}); | |
return p2; | |
}).then(function (data) { | |
console.log(data); | |
}); | |
// FAIL |
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 --version v0.11.13 | |
// node --harmony | |
// | |
// Works, but not as pretty | |
// | |
var p1 | |
; | |
p1 = new Promise(function (resolve, reject) { | |
var p2 | |
; | |
p2 = new Promise(function (resolve, reject) { | |
resolve("Hey"); | |
}); | |
p2.then(resolve, reject); | |
}).then(function (data) { | |
console.log(data); | |
}); | |
// Hey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment