docs: function resolve(promise) {
      var method = promise.state === FULFILLED ? 'onFulfilled' : 'onRejected';
      var arg = method === 'onFulfilled' ? promise.value : promise.reason;
      var handler, value;
  
      nextTick(function() {
        var isPromise;
  
        while (promise.handlers[0]) {
          handler = promise.handlers.shift();
  
          try {
            value = handler[method](arg);
  
            // Handle "thenables" as well as Promises
            isPromise = value instanceof Promise || value && isFunc(value.then);
  
            if (isPromise) {
              value.then(function(value) { fulfill(handler.promise, value); },
                         function(reason) { reject(handler.promise, reason); });
            } else {
              fulfill(handler.promise, value);
            }
          } catch(err) {
            reject(handler.promise, err);
          }
        }
      });
  
      return promise;
    }