util/promises.js
function promiseWithError( result, callback) {
        var deferred = Q.defer();
        deferred.resolve(result);
        if ( typeof callback === 'function' ) {
            callback(null, result);
        }
        return deferred.promise;
    }
function promiseWithError( result, callback) {
        var deferred = Q.defer();
        deferred.resolve(result);
        if ( typeof callback === 'function' ) {
            callback(null, result);
        }
        return deferred.promise;
    }
function promiseWithError ( result , callback ) { var deferred = Q . defer ( ) ; deferred . resolve ( result ) ; if ( typeof callback === 'function' ) { callback ( null , result ) ; } return deferred . promise ; }
Creates a promise that only returns a result to be used when promise is expected
but the result is already known and calls the callback if given
@param result - the result value
@param callback - optional, a callback with signature function( error, result).
if given this one will be called despite returning a promise
@returns {*|promise} - the promise
Creates a promise that only returns a result to be used when promise is expected but the result is already known and calls the callback if given