4 ms·
I would also add that callback signatures should always follow: function (err, result) { //... }
by roskilli 12y ago
I would also add that callback signatures should always follow:
function (err, result) {
//...
}
- jimmaswell 12y agoisn't it usually just function(e){ and then e might have some kind of indicator that it's an error
- notduncansmith 12y agoUsually, when dealing with Javascript, you'll see function (e) { as the signature for DOM function callbacks, where e refers to the event object.
- zachrose 12y agoSimilarly, `function(err, result)` is nice because HTTP handlers often use `function(req, res)`, where the res is a response object. Fumbling over this kind of thing while nesting async calls in HTTP handlers is a minor annoyance.
- notduncansmith 12y agoYou should definitely be using promises. Q is a good library. Don't worry about performance, I can say with extreme confidence that promise execution speed is not your bottleneck. In that 0.01% of times where it is, use Bluebird.
- zachrose 12y agoExcellent call.