Skip to content

Instantly share code, notes, and snippets.

@bricecarpentier
Created April 30, 2018 10:19
Show Gist options
  • Save bricecarpentier/573cc93daf6e1f3f89d71bea756dbc3c to your computer and use it in GitHub Desktop.
Save bricecarpentier/573cc93daf6e1f3f89d71bea756dbc3c to your computer and use it in GitHub Desktop.
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