promise.js
function adopt(promise, state, value, adoptee) {
  var queue = promise._value;
  promise._state = state;
  promise._value = value;

  if (adoptee && state === PendingPromise) {
    adoptee._state(value, void 0, void 0, {
      promise: promise,
      resolve: void 0,
      reject: void 0
    });
  }

  for (var i = 0; i < queue.length; i++) {
    var next = queue[i];
    promise._state(
      value,
      next.onFulfilled,
      next.onRejected,
      next.deferred
    );
  }
  queue.length = 0;

  // Determine if this rejected promise will be "handled".
  if (state === RejectedPromise && promise._isChainEnd) {
    setTimeout(function() {
      if (promise._isChainEnd) {
        onPossiblyUnhandledRejection(value, promise);
      }
    }, 0);
  }
}
function adopt(promise, state, value, adoptee) {
  var queue = promise._value;
  promise._state = state;
  promise._value = value;

  if (adoptee && state === PendingPromise) {
    adoptee._state(value, void 0, void 0, {
      promise: promise,
      resolve: void 0,
      reject: void 0
    });
  }

  for (var i = 0; i < queue.length; i++) {
    var next = queue[i];
    promise._state(
      value,
      next.onFulfilled,
      next.onRejected,
      next.deferred
    );
  }
  queue.length = 0;

  // Determine if this rejected promise will be "handled".
  if (state === RejectedPromise && promise._isChainEnd) {
    setTimeout(function() {
      if (promise._isChainEnd) {
        onPossiblyUnhandledRejection(value, promise);
      }
    }, 0);
  }
}
function adopt ( promise , state , value , adoptee ) { var queue = promise . _value ; promise . _state = state ; promise . _value = value ; if ( adoptee && state === PendingPromise ) { adoptee . _state ( value , void 0 , void 0 , { promise : promise , resolve : void 0 , reject : void 0 } ) ; } for ( var i = 0 ; i < queue . length ; i ++ ) { var next = queue [ i ] ; promise . _state ( value , next . onFulfilled , next . onRejected , next . deferred ) ; } queue . length = 0 ; // Determine if this rejected promise will be "handled". if ( state === RejectedPromise && promise . _isChainEnd ) { setTimeout ( function ( ) { if ( promise . _isChainEnd ) { onPossiblyUnhandledRejection ( value , promise ) ; } } , 0 ) ; } }
Transitions the state of promise to another state. This is only ever called
on with a promise that is currently in the Pending state.

@param {!Promise} promise
@param {function(this:Promise,*=,function(*=),function(*=),Deferred):!Promise} state
@param {*=} value
Transitions the state of promise to another state . This is only ever called on with a promise that is currently in the Pending state .