src/promissory-arbiter.js
function evaluateLatch (resolver, options) {
    var
      settlementLatch = options.settlementLatch,
      latch = options.latch,
      promise = resolver.promise,
      fulfilled = promise.fulfilled,
      pending = promise.pending,
      rejected = promise.rejected,
      settled = fulfilled + rejected,
      maxFulfilled = fulfilled + pending,
      total = fulfilled + pending + rejected;

    if (resolver.settled) {
      return resolver.settled;
    }

    if (!settlementLatch && latch >= 1 && maxFulfilled < latch
      || !settlementLatch && latch < 1 && maxFulfilled / total < latch
      || settlementLatch && latch >= 1 && total < latch
      || settlementLatch && latch < 1 && total === 0
    ) {
      resolver.settled = true;
      return resolver.reject(resolver.rejectedValues);
    }

    if (!settlementLatch && latch >= 1 && fulfilled >= latch
      || !settlementLatch && latch < 1 && fulfilled / total >= latch
      || settlementLatch && latch >= 1 && settled >= latch
      || settlementLatch && latch < 1 && settled / total >= latch
    ) {
      resolver.settled = true;
      return settlementLatch
        ? resolver.fulfill(
          resolver.fulfilledValues.concat(resolver.rejectedValues)
        ) : resolver.fulfill(resolver.fulfilledValues);
    }

    return resolver.settled;
  }
function evaluateLatch (resolver, options) {
    var
      settlementLatch = options.settlementLatch,
      latch = options.latch,
      promise = resolver.promise,
      fulfilled = promise.fulfilled,
      pending = promise.pending,
      rejected = promise.rejected,
      settled = fulfilled + rejected,
      maxFulfilled = fulfilled + pending,
      total = fulfilled + pending + rejected;

    if (resolver.settled) {
      return resolver.settled;
    }

    if (!settlementLatch && latch >= 1 && maxFulfilled < latch
      || !settlementLatch && latch < 1 && maxFulfilled / total < latch
      || settlementLatch && latch >= 1 && total < latch
      || settlementLatch && latch < 1 && total === 0
    ) {
      resolver.settled = true;
      return resolver.reject(resolver.rejectedValues);
    }

    if (!settlementLatch && latch >= 1 && fulfilled >= latch
      || !settlementLatch && latch < 1 && fulfilled / total >= latch
      || settlementLatch && latch >= 1 && settled >= latch
      || settlementLatch && latch < 1 && settled / total >= latch
    ) {
      resolver.settled = true;
      return settlementLatch
        ? resolver.fulfill(
          resolver.fulfilledValues.concat(resolver.rejectedValues)
        ) : resolver.fulfill(resolver.fulfilledValues);
    }

    return resolver.settled;
  }
function evaluateLatch ( resolver , options ) { var settlementLatch = options . settlementLatch , latch = options . latch , promise = resolver . promise , fulfilled = promise . fulfilled , pending = promise . pending , rejected = promise . rejected , settled = fulfilled + rejected , maxFulfilled = fulfilled + pending , total = fulfilled + pending + rejected ; if ( resolver . settled ) { return resolver . settled ; } if ( ! settlementLatch && latch >= 1 && maxFulfilled < latch || ! settlementLatch && latch < 1 && maxFulfilled / total < latch || settlementLatch && latch >= 1 && total < latch || settlementLatch && latch < 1 && total === 0 ) { resolver . settled = true ; return resolver . reject ( resolver . rejectedValues ) ; } if ( ! settlementLatch && latch >= 1 && fulfilled >= latch || ! settlementLatch && latch < 1 && fulfilled / total >= latch || settlementLatch && latch >= 1 && settled >= latch || settlementLatch && latch < 1 && settled / total >= latch ) { resolver . settled = true ; return settlementLatch ? resolver . fulfill ( resolver . fulfilledValues . concat ( resolver . rejectedValues ) ) : resolver . fulfill ( resolver . fulfilledValues ) ; } return resolver . settled ; }
Resolves the latch according to `options`. Computes the hypothetical max and resolves if is not met.
Resolves the latch according to options . Computes the hypothetical max and resolves if is not met .