Created
February 26, 2023 13:25
-
-
Save aluissp/c1f5ede4a15150368f677a49bb2c9e4c to your computer and use it in GitHub Desktop.
utility 'to' function to work with promises
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
const to = (promise) => { | |
return promise | |
.then((data) => { | |
return [null, data]; | |
}) | |
.catch((err) => [err, null]); | |
}; | |
exports.to = to; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment