function settlePromise (p, state, value) {
      var i = 0
          , len = p._c;

      // 2.1.2
      // 2.1.3
      if (p._s === $pending) {
          // 2.1.1.1
          p._s = state;
          p._v = value;

          if (state === $rejected) {
              if (isLongStackTrace && isError(value)) {
                  value.longStack = genStackInfo(value, p);
              }

              scheduleUnhandledRejection(p);
          }

          // 2.2.4
          while (i < len) {
              scheduleHandler(p, p[i++]);
          }
      }

      return p;
  }
Resolve or reject a promise.
@private
@param  {Yaku} p
@param  {Integer} state
@param  {Any} value