Skip to content

Instantly share code, notes, and snippets.

@samgiles
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samgiles/41e37c87266e71d531e9 to your computer and use it in GitHub Desktop.
Save samgiles/41e37c87266e71d531e9 to your computer and use it in GitHub Desktop.
API style?
// THIS?
// #wrap(func) - Wrap the function in error handling code
// #wrap(context, func) - Wrap the function in error handling code with additional context
function wrap(context, func) {
if (func === undefined) {
func = context;
context = {};
}
return doThing(context, func)
}
// OR THIS?
// #wrap(func) - Wrap the function in error handling code
function wrap(func) {
return doThing({}, func);
}
// #wrapWithContext(context, func) - Wrap the function in error handling code with additional context
function wrapWithContext(context, func) {
return doThing(context, func);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment