Skip to content

Instantly share code, notes, and snippets.

@ashtonmeuser
Created July 5, 2019 20:56
Show Gist options
  • Select an option

  • Save ashtonmeuser/248cf73bcd76191616e6ad1acd1160fe to your computer and use it in GitHub Desktop.

Select an option

Save ashtonmeuser/248cf73bcd76191616e6ad1acd1160fe to your computer and use it in GitHub Desktop.
Execute or abandon function based on result of assertion function taking same arguments
const wrapper = (as, fn) => ((...args) => {
try {
as(...args);
} catch (error) {
return () => {};
}
return fn(...args);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment