lib/promise.js
function wait(args, fn) {
    var resolved = false;
    args = argsToArray(arguments);
    fn = args.pop();
    var p = when(args);
    return function waiter() {
        if (!resolved) {
            var args = arguments;
            return p.chain(function () {
                resolved = true;
                p = null;
                return fn.apply(this, args);
            }.bind(this));
        } else {
            return when(fn.apply(this, arguments));
        }
    };
}
function wait(args, fn) {
    var resolved = false;
    args = argsToArray(arguments);
    fn = args.pop();
    var p = when(args);
    return function waiter() {
        if (!resolved) {
            var args = arguments;
            return p.chain(function () {
                resolved = true;
                p = null;
                return fn.apply(this, args);
            }.bind(this));
        } else {
            return when(fn.apply(this, arguments));
        }
    };
}
function wait ( args , fn ) { var resolved = false ; args = argsToArray ( arguments ) ; fn = args . pop ( ) ; var p = when ( args ) ; return function waiter ( ) { if ( ! resolved ) { var args = arguments ; return p . chain ( function ( ) { resolved = true ; p = null ; return fn . apply ( this , args ) ; } . bind ( this ) ) ; } else { return when ( fn . apply ( this , arguments ) ) ; } } ; }
Ensures that a promise is resolved before a the function can be run.

For example suppose you have to ensure that you are connected to a database before you execute a function.

```
var findUser = comb.wait(connect(), function findUser(id){
//this wont execute until we are connected
return User.findById(id);
});

comb.when(findUser(1), findUser(2)).then(function(users){
var user1 = users[0], user2 = users[1];
});

```

@param args variable number of arguments to wait on. See {@link comb.when}.
@param {Function} fn function that will wait.
@return {Function} a function that will wait on the args to resolve.
@memberOf comb
@static
Ensures that a promise is resolved before a the function can be run .