static all(promises) {
    return new mr.MockPromise((resolve, reject) => {
      let toFulfill = promises.length;
      const values = [];

      if (!toFulfill) {
        resolve(values);
        return;
      }

      const onFulfill = (index, value) => {
        toFulfill--;
        values[index] = value;
        if (toFulfill == 0) {
          resolve(values);
        }
      };

      const onReject = reason => {
        reject(reason);
      };

      for (let i = 0, promise; i < promises.length; i++) {
        promise = promises[i];
        mr.MockPromise.resolve(promise).then(onFulfill.bind(null, i), onReject);
      }
    });
  }
/**
   * @param {!Array} promises
   * @return {!mr.MockPromise<!Array>} A Promise that receives a list of
   *     every fulfilled value once every input Promise is successfully
   *     fulfilled, or is rejected with the first rejection reason immediately
   *     after it is rejected.
   */
@param {!Array} promises
@return {!mr.MockPromise} A Promise that receives a list of
every fulfilled value once every input Promise is successfully
fulfilled, or is rejected with the first rejection reason immediately
after it is rejected.
@param { !Array } promises @return { !mr . MockPromise } A Promise that receives a list of every fulfilled value once every input Promise is successfully fulfilled or is rejected with the first rejection reason immediately after it is rejected .
static all(promises) {
    return new mr.MockPromise((resolve, reject) => {
      let toFulfill = promises.length;
      const values = [];
      if (!toFulfill) {
        resolve(values);
        return;
      }
      const onFulfill = (index, value) => {
        toFulfill--;
        values[index] = value;
        if (toFulfill == 0) {
          resolve(values);
        }
      };
      const onReject = reason => {
        reject(reason);
      };
      for (let i = 0, promise; i < promises.length; i++) {
        promise = promises[i];
        mr.MockPromise.resolve(promise).then(onFulfill.bind(null, i), onReject);
      }
    });
  }
static all ( promises ) { return new mr . MockPromise ( ( resolve , reject ) => { let toFulfill = promises . length ; const values = [ ] ; if ( ! toFulfill ) { resolve ( values ) ; return ; } const onFulfill = ( index , value ) => { toFulfill -- ; values [ index ] = value ; if ( toFulfill == 0 ) { resolve ( values ) ; } } ; const onReject = reason => { reject ( reason ) ; } ; for ( let i = 0 , promise ; i < promises . length ; i ++ ) { promise = promises [ i ] ; mr . MockPromise . resolve ( promise ) . then ( onFulfill . bind ( null , i ) , onReject ) ; } } ) ; }
@param {!Array} promises
 @return {!mr.MockPromise<!Array>} A Promise that receives a list of
     every fulfilled value once every input Promise is successfully
     fulfilled, or is rejected with the first rejection reason immediately
     after it is rejected.
@param { !Array } promises @return { !mr . MockPromise<!Array > } A Promise that receives a list of every fulfilled value once every input Promise is successfully fulfilled or is rejected with the first rejection reason immediately after it is rejected .