Question: In my node js App, I have a function that checks if you have the permissions:

```
//queryPermissions is an object that contains all possible permissions:
//each property of queryPermission is an object containing the values to be checked
for (var key in queryPermissions) {
    if (queryPermissions.hasOwnProperty(key)) {
        promisesArray.push(checkThis(key, req.method));
    }
}

Q.all(promisesArray).then(function(response) {
    response.forEach(function(value) {
        //response is an array with all promises' resolved values
        //if all values are true -> access granted
        //if one or more values are false -> access denied
    }
}

```

This works good, but if only one of the values returned by checkThis inside the for loop is false, than the result would be access denied;
so it is not efficient to continue to check other permissions after the first one that resoves with false;
CheckThis returns a promise but sometimes it needs to wait for a query result, sometimes it resolves immediately, it depends.

Is there a way I can break the loop (if it is not finished yet) when the first "checkThis" returns false?

Answer: 
Not with any native `Q` function. You could however write an [`every` method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) for promises yourself (loosely based on `Q.all`):

```
Q.every = function every(promises) {
    return Q.when(promises, function (promises) {
        var countDown = 0;
        var deferred = defer();
        for (var i=0; i<promises.length; i++) {
            var promise = promises[i];
            var snapshot;
            if (
                Q.isPromise(promise) &&
                (snapshot = promise.inspect()).state === "fulfilled"
            ) {
                if (!snapshot.value) {
                    deferred.resolve(false);
                    return deferred.promise;
                }
            } else {
                ++countDown;
                q.when(
                    promise,
                    function (value) {
                        if (!value)
                            deferred.resolve(false);
                        else if (--countDown === 0)
                            deferred.resolve(true);
                    },
                    deferred.reject,
                    (function(index) {
                        return function (progress) {
                            deferred.notify({ index: index, value: progress });
                        };
                    }(i));
                );
            }
        }
        if (countDown === 0) {
            deferred.resolve(true);
        }
        return deferred.promise;
    });
}

```
It's not possible. Indeed, `Q.all` run parallel promises, so when you want to break, the other promises are still running. So they can't be stopped. One way is to use `Q.spread` but therefore the promises are no more parallel :(.