5 ms·
async: async.waterfall([ fn1, fn2, fn3 ], function(err, result) { }); Q: resultP = [ fn1, fn2, fn3 ].reduce(Q.when, void 0); result
by jkrems 13y ago
async:
async.waterfall([
fn1, fn2, fn3
], function(err, result) {
});
Q:
resultP = [ fn1, fn2, fn3 ].reduce(Q.when, void 0);
resultP
.then(function(result) {});
.catch(function(err) {});
If you chain thens in Q, you are not doing it right (imho).
- nailer 13y agoQ docs show both. Either way: .waterfall() is still simpler.
- bluepnume 13y agoIt would be trivial to create a q.series or q.waterfall abstraction. The real benefits of promises are that we get back `return`, `throw`, `try` and `catch`, not that it makes our code 'look' more sequential, which is totally possible using callbacks and async.js.
- tel 13y agoWaterfall is an easier top-level API that hides a clean low-level API. When it's all you need and it works well then you won't want to switch. When it breaks or you want it to behave better then a nice low-level API is beneficial.