Skip to content

Instantly share code, notes, and snippets.

@kumikoda
Created May 12, 2014 23:49
Show Gist options
  • Save kumikoda/3e9094fdac1d20429e53 to your computer and use it in GitHub Desktop.
Save kumikoda/3e9094fdac1d20429e53 to your computer and use it in GitHub Desktop.
returning callbacks early
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