src/polyfill/promise.js
function handleThenable(promise, value) {
  var done, then;

  // Attempt to get the `then` method from the thenable (if it is a thenable)
  try {
    if (! (then = utils.thenable(value))) {
      return false;
    }
  } catch (err) {
    rejectPromise(promise, err);
    return true;
  }

  // Ensure that the promise did not attempt to fulfill with itself
  if (promise === value) {
    rejectPromise(promise, new TypeError('Circular resolution of promises'));
    return true;
  }

  try {
    // Wait for the thenable to fulfill/reject before moving on
    then.call(value,
      function(subValue) {
        if (! done) {
          done = true;

          // Once again look for circular promise resolution
          if (value === subValue) {
            rejectPromise(promise, new TypeError('Circular resolution of promises'));
            return;
          }

          resolvePromise(promise, subValue);
        }
      },
      function(subValue) {
        if (! done) {
          done = true;

          rejectPromise(promise, subValue);
        }
      }
    );
  } catch (err) {
    if (! done) {
      done = true;

      rejectPromise(promise, err);
    }
  }

  return true;
}
function handleThenable(promise, value) {
  var done, then;

  // Attempt to get the `then` method from the thenable (if it is a thenable)
  try {
    if (! (then = utils.thenable(value))) {
      return false;
    }
  } catch (err) {
    rejectPromise(promise, err);
    return true;
  }

  // Ensure that the promise did not attempt to fulfill with itself
  if (promise === value) {
    rejectPromise(promise, new TypeError('Circular resolution of promises'));
    return true;
  }

  try {
    // Wait for the thenable to fulfill/reject before moving on
    then.call(value,
      function(subValue) {
        if (! done) {
          done = true;

          // Once again look for circular promise resolution
          if (value === subValue) {
            rejectPromise(promise, new TypeError('Circular resolution of promises'));
            return;
          }

          resolvePromise(promise, subValue);
        }
      },
      function(subValue) {
        if (! done) {
          done = true;

          rejectPromise(promise, subValue);
        }
      }
    );
  } catch (err) {
    if (! done) {
      done = true;

      rejectPromise(promise, err);
    }
  }

  return true;
}
function handleThenable ( promise , value ) { var done , then ; // Attempt to get the `then` method from the thenable (if it is a thenable) try { if ( ! ( then = utils . thenable ( value ) ) ) { return false ; } } catch ( err ) { rejectPromise ( promise , err ) ; return true ; } // Ensure that the promise did not attempt to fulfill with itself if ( promise === value ) { rejectPromise ( promise , new TypeError ( 'Circular resolution of promises' ) ) ; return true ; } try { // Wait for the thenable to fulfill/reject before moving on then . call ( value , function ( subValue ) { if ( ! done ) { done = true ; // Once again look for circular promise resolution if ( value === subValue ) { rejectPromise ( promise , new TypeError ( 'Circular resolution of promises' ) ) ; return ; } resolvePromise ( promise , subValue ) ; } } , function ( subValue ) { if ( ! done ) { done = true ; rejectPromise ( promise , subValue ) ; } } ) ; } catch ( err ) { if ( ! done ) { done = true ; rejectPromise ( promise , err ) ; } } return true ; }
When a promise resolves with another thenable, this function handles delegating control and passing around values  @param {child} the child promise that values will be passed to @param {value} the thenable value from the previous promise @return boolean
When a promise resolves with another thenable this function handles delegating control and passing around values