Created
May 12, 2014 23:49
-
-
Save kumikoda/3e9094fdac1d20429e53 to your computer and use it in GitHub Desktop.
returning callbacks early
This file contains hidden or 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 someAsyncFn (cb) { | |
if (somethingWrong) { | |
cb(err) | |
} else { | |
cb(null, 'yay') | |
} | |
... | |
// potentially some things happen here | |
} | |
function careful (cb) { | |
if (somethingWrong) { | |
return cb(err) | |
} else { | |
return cb(null, 'yay') | |
} | |
... | |
// stuff down here does not happen | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment