4 ms·
Q has some utility functions around wrapping node style callbacks that make the code a bit shorter and arguably more easy to understand. var Q = require('q
by modiho 13y ago
Q has some utility functions around wrapping node style callbacks that make the code a bit shorter and arguably more easy to understand.
var Q = require('q');
function getUserFriends(userName) {
return Q.nfcall(db.users.findOne, {name:userName});
}
function foundOne(user) {
return Q.nfcall(db.friends.find, {userId:user.id});
}
function foundFriends(friends) { ... }
getUserFriends.then(foundOne).then(foundFriends);
- prezjordan 13y agoThat's much better, thanks for sharing