Created
March 12, 2014 10:07
-
-
Save riston/9504103 to your computer and use it in GitHub Desktop.
Callback handling styles...
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
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