Skip to content

Instantly share code, notes, and snippets.

@choffmeister
Created March 16, 2015 13:11
Show Gist options
  • Save choffmeister/90933eca8de748b884cb to your computer and use it in GitHub Desktop.
Save choffmeister/90933eca8de748b884cb to your computer and use it in GitHub Desktop.
Bluebird.prototype.flatThen = function (promise, transform) {
return new Bluebird(function (resolve, reject) {
promise
.then(function (value1) {
transform(value1)
.then(function (value2) {
resolve(value2);
})
.catch(function (err2) {
reject(err2);
});
})
.catch(function (err1) {
reject(err1);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment