(answerPs)
| 18881 | */ |
| 18882 | Q.race = race; |
| 18883 | function race(answerPs) { |
| 18884 | return promise(function (resolve, reject) { |
| 18885 | // Switch to this once we can assume at least ES5 |
| 18886 | // answerPs.forEach(function (answerP) { |
| 18887 | // Q(answerP).then(resolve, reject); |
| 18888 | // }); |
| 18889 | // Use this in the meantime |
| 18890 | for (var i = 0, len = answerPs.length; i < len; i++) { |
| 18891 | Q(answerPs[i]).then(resolve, reject); |
| 18892 | } |
| 18893 | }); |
| 18894 | } |
| 18895 | |
| 18896 | Promise.prototype.race = function () { |
| 18897 | return this.then(Q.race); |