Skip to content

Instantly share code, notes, and snippets.

@gnitnuj gnitnuj/GoifyPromise.js
Last active Jun 26, 2018

Embed
What would you like to do?
module to handle async/await error handling in a golang kinda way
// this file exists just to name the gist, and because gist ordering is asciibetical, it's name starts with a capital letter.
/**
* goifyPromise
* given a promise, return an array that has the data, and also possibly the error
* @param {Promise}
* @returns {Array}
*/
module.exports = promise => {
return promise
.then(data => {
return [null, data];
})
.catch(err => {
return [err];
});
};
{
"name": "goify-promise",
"version": "0.1.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.