← Back To API Reference

Promise.race

Promise.race(Iterable<any>|Promise<Iterable<any>> input) -> Promise

Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.

This method is only implemented because it's in the ES6 standard. If you want to race promises to fulfillment the .any method is more appropriate as it doesn't qualify a rejected promise as the winner. It also has less surprises: .race must become infinitely pending if an empty array is passed but passing an empty array to .any is more usefully a RangeError