Skip to content

Instantly share code, notes, and snippets.

@coolaj86
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolaj86/1881e0e37780e1e103d4 to your computer and use it in GitHub Desktop.
Save coolaj86/1881e0e37780e1e103d4 to your computer and use it in GitHub Desktop.
// 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
// 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