Last active
August 29, 2015 14:17
-
-
Save samgiles/41e37c87266e71d531e9 to your computer and use it in GitHub Desktop.
API style?
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
// 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