Created
April 30, 2018 10:19
-
-
Save bricecarpentier/573cc93daf6e1f3f89d71bea756dbc3c 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
function maybe(fn) { | |
try { | |
return fn(); | |
} catch(error) { | |
if (error instanceof TypeError) { | |
return undefined; | |
} | |
throw error; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment