promise.js
function RejectedPromise(reason, unused, onRejected, deferred) {
  if (!onRejected) {
    deferredAdopt(deferred, RejectedPromise, reason);
    return this;
  }
  if (!deferred) {
    deferred = new Deferred(this.constructor);
  }
  defer(tryCatchDeferred(deferred, onRejected, reason));
  return deferred.promise;
}
function RejectedPromise(reason, unused, onRejected, deferred) {
  if (!onRejected) {
    deferredAdopt(deferred, RejectedPromise, reason);
    return this;
  }
  if (!deferred) {
    deferred = new Deferred(this.constructor);
  }
  defer(tryCatchDeferred(deferred, onRejected, reason));
  return deferred.promise;
}
function RejectedPromise ( reason , unused , onRejected , deferred ) { if ( ! onRejected ) { deferredAdopt ( deferred , RejectedPromise , reason ) ; return this ; } if ( ! deferred ) { deferred = new Deferred ( this . constructor ) ; } defer ( tryCatchDeferred ( deferred , onRejected , reason ) ) ; return deferred . promise ; }
The Rejected Promise state. Calls onRejected with the resolved value of
this promise, creating a new promise.

If there is no onRejected, returns the current promise to avoid an promise
instance.

@this {!Promise} The current promise
@param {*=} reason The current promise's rejection reason.
@param {function(*=)=} unused
@param {function(*=)=} onRejected
@param {Deferred} deferred A deferred object that holds a promise and its
resolve and reject functions. It IS NOT passed when called from
Promise#then to save an object instance (since we may return the current
promise). It IS passed in when adopting the Rejected state from the
Pending state.
@returns {!Promise}
The Rejected Promise state . Calls onRejected with the resolved value of this promise creating a new promise .