Created
December 12, 2017 23:19
-
-
Save tylerbuchea/142e8cc65f10238d164fa88fcc5a808b 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
/** | |
* @param { Promise } promise | |
* @param { Object= } errorExt - Additional Information you can pass to the err object | |
* @return { Promise } | |
*/ | |
function to(promise, errorExt) { | |
return promise | |
.then(function (data) { return [null, data]; }) | |
.catch(function (err) { | |
if (errorExt) { | |
Object.assign(err, errorExt); | |
} | |
return [err, undefined]; | |
}); | |
} | |
export { to }; | |
export default to; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment