Last active
November 27, 2023 05:45
-
-
Save justforuse/d2a0e9ed917a76244ee73e0cd883fbea to your computer and use it in GitHub Desktop.
safe await
This file contains hidden or 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
export function safeAwait(promise, finallyFunc) { | |
return promise.then(data => { | |
return [ undefined, data ] | |
}).catch(error => { | |
return [ error, undefined ] | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typescript version: