Is there a built-in function to configure a race in the q
JavaScript library?
Example:
function fnThatReturnsAPromise1() { /*...*/ }
function fnThatReturnsAPromise2() { /*...*/ }
//Pseudocode: I want to have the first one of these functions that resolves, be the result
q.race([fnThatReturnsAPromise1,fnThatReturnsAPromise2])
.then(function(resultOfWinner) {
// ...
});
Edit: there appears to be a race method in the source, but it is not mentioned in the documentation. https://github.com/kriskowal/q/blob/v1/q.js#L738