onSettled = function(index, fulfilled, result) {
      'use strict';
      toSettle--;
      results[index] = fulfilled ? {fulfilled: true, value: result} :
                                   {fulfilled: false, reason: result};
      if (toSettle == 0) {
        resolve(results);
      }
    }
@param {!Array<?(goog.Promise<TYPE>|goog.Thenable<TYPE>|Thenable|*)>}
    promises
@return {!goog.Promise<!Array<{
    fulfilled: boolean,
    value: (TYPE|undefined),
    reason: (*|undefined)}>>} A Promise that resolves with a list of
        result objects once all input Promises (or Promise-like) have
        settled. Each result object contains a 'fulfilled' boolean indicating
        whether an input Promise was fulfilled or rejected. For fulfilled
        Promises, the resulting value is stored in the 'value' field. For
        rejected Promises, the rejection reason is stored in the 'reason'
        field.
@template TYPE