Start a new topic

async waterfall

Any chance you will support 'waterfall' in the async module?

I've actually implemented a quick and dirty version of waterfall in one of our collection hooks:

```function waterfall (functions, callback) {

var execute = function (functions, lastResult) {


callback(null, lastResult);


functions[0](lastResult, function(error, newResult) {

execute(functions.slice(1), newResult);




//first function takes only a callback

functions[0]( function (error, result){

execute(functions.slice(1), result);



However, promises (used in the javascript sdk) are generally awesome, and coincidentally all but eliminate the need for "waterfall" once you convert callback-based code to being promise-based. If you have access to a working version of the BL CLI (, I'd **highly** recommend investing time in add a good promises library to "common code", and converting as much of your BL to be promise-based as humanly possible (we plan to do this as soon as a CLI issue on Ubuntu is ironed out)
sorry about the formatting, here's a gist:
oh wow I totally missed the "common code" section of that doc.

I actually kept getting frustrated not being able to use promises... yeah, guess I should add one there.

No problem, glad to be of help! :-)
have you had any luck loading a library into utils?

I can't even get the example they have to work.
I'm still waiting for a working Ubuntu version of the CLI, but I'll let you know if and when I am able to try something!
I tried it today with Q but setTimeout isn't supported so the whole thing just ends up failing.

Not really sure where to go with this when any setTimeout usage kills it.
Ah, I haven't been able to try anything yet since I'm still waiting on a fix for the Ubuntu CLI. At this point, I would just start searching github for promise libraries and making sure they don't have setTimeout anywhere :-/
Login or Signup to post a comment