Skip to content

Instantly share code, notes, and snippets.

@riston
Created March 12, 2014 10:07
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 riston/9504103 to your computer and use it in GitHub Desktop.
Save riston/9504103 to your computer and use it in GitHub Desktop.
Callback handling styles...
db.findById(id, function (err, res) {
if (err) {
return cb(err);
}
// Handle result
return cb(null, _.transform(res));
});
// vs this style
db.findById(id, function (err, res) {
if (err) {
return cb(err);
} else {
// Handle result
return cb(null, _.transform(res));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment