same example with async control flow library and node style callback conventions
function getUserInfo(callback) { async.parallel([api.getUser, api.getFriends, api.getPhoto], callback) }
function getUserInfo(callback) { async.parallel([api.getUser, api.getFriends, api.getPhoto], callback) }
With async/await you only need to deal with errors at the level you actually care about them (using the language build in try/catch block).
function getUserInfo(cb) {
Promise.all([
api.getUser(),
api.getFriends(),
api.getPhoto(),
]).then(
([user, friends, photo]) =>
cb(null, {user, friends, photo}),
cb,
);
}I just prefer node style callbacks, so I wrap libraries with promise based APIs with callback based wrappers.
hopefully i'm not the only one.