Moved out of "limit" to avoid the extra closure
184053
function limitNotifySubscribers(value, event) {
    if (!event || event === defaultEvent) {
        this._limitChange(value);
    } else if (event === 'beforeChange') {
        this._limitBeforeChange(value);
    } else {
        this._origNotifySubscribers(value, event);
    }
}
297788
def limit(self, v):
        
        if not (v is None or isinstance(v, six.integer_types)):
            raise TypeError
        if v == self._limit:
            return self

        if v < 0:
            raise QueryException("Negative limit is not allowed")

        clone = copy.deepcopy(self)
        clone._limit = v
        return clone
1201868
def _pop_entities(self, limit=50):
        
        pop = self.data['entities'][:limit]
        del self.data['entities'][:limit]
        return pop
1344751
function(offset, limit){
    var oldOffset = this.offset;
    var oldLimit = this.limit;
    var delta = false;

    if (oldOffset != offset || oldLimit != limit)
    {
      this.offset = offset;
      this.limit = limit;

      delta = this.applyRule();

      this.emit_rangeChanged(oldOffset, oldLimit);
    }

    return delta;
  }
371039
function closeExtension(done) {
            var extension = self.extension;

            if (extension && !extension.closed) {
                extension.removeListener('error', handlers.relayError);

                extension.close(done);
            } else {
                done(null);
            }
        }
566609
protected function limitPending()
    {
        $offset     = $this->pending['limit']['offset'];
        $num        = $this->pending['limit']['number'];
        $this->data = array_slice($this->data, $offset, $num);
    }
605205
protected function _truncate()
    {
        if (!$this->getLimit()->isNull()) {
            if (is_null($this->getLimit()->getCount())) {
                $this->_output = array_splice($this->_output, $this->getLimit()->getStart());
            } else {
                $this->_output = array_splice($this->_output, $this->getLimit()->getStart(), $this->getLimit()->getCount());
            }
        }
    }
78996
private int calcLastPageSkip(int total, int skip, int limit) {
        if (skip > total - limit) {
            return skip;
        }
        if (total % limit > 0) {
            return total - total % limit;
        }
        return total - limit;
    }
745039
def fetch_closed_orders(self, limit: int) -> List[Order]:
        """"""
        return self._fetch_orders_limit(self._closed_orders, limit)
1261642
protected int handleGetLimit(int field, int limitType) {
        if (field == ERA) {
            if (limitType == MINIMUM || limitType == GREATEST_MINIMUM) {
                return BEFORE_MINGUO;
            } else {
                return MINGUO;
            }
        }
        return super.handleGetLimit(field, limitType);
    }
1333120
def is_rate_limit_exceeded(self):
        """"""
        history = self.get_history()
        if history.amount_api_calls >= settings.UNSHORTEN_DAILY_LIMIT:
            return True
        return False
341668
function limit() {
  const args = Array.from(arguments);
  const onChange = get(args, isFunction, noop);
  const error = new Error('Too Many Requests');
  error.status = 429;
  const options = Object.assign({
    err: error,
    mid: 100,
    high: 500,
  }, get(args, isObject));
  debug('limit options:', options);
  const mid = parseInt(options.mid, 10);
  const high = parseInt(options.high, 10);
  if (isNaN(mid) || isNaN((high))) {
    throw new Error('mid and high must be a number');
  }
  if (mid <= 0 || high <= 0) {
    throw new Error('mid and high must gt 0');
  }
  if (mid >= high) {
    throw new Error('high must be gt mid');
  }
  let handlingReqTotal = 0;
  let status = '';
  let throwError = options.throwError;
  /* istanbul ignore else */
  if (isUndefined(throwError)) {
    throwError = true;
  }
  const pass = options.pass || noop;
  return (ctx, next) => {
    function checkStatus() {
      if (handlingReqTotal > high) {
        /* istanbul ignore else */
        if (status !== 'high') {
          status = 'high';
          onChange(status);
        }
        /* istanbul ignore else */
        if (throwError) {
          throw options.err;
        }
      } else if (handlingReqTotal > mid) {
        /* istanbul ignore else */
        if (status !== 'mid') {
          status = 'mid';
          onChange(status);
        }
      } /* istanbul ignore else */ else if (status !== 'low') {
        status = 'low';
        onChange(status);
      }
    }

    function done(err) {
      handlingReqTotal -= 1;
      checkStatus();
      if (err) {
        throw err;
      }
    }
    if (pass(ctx)) {
      return next();
    }

    handlingReqTotal += 1;
    checkStatus();
    return next().then(done, done);
  };
}
1303256
private void closeValueLength(int value, int index) {
    int initialValue = toIntUnsigned(getValue(index));
    setLength(index, (short) (value - initialValue));
  }
493078
private static long addUnsignedReturnOverflow(Slice left, Slice right, Slice result, boolean resultNegative)
    {
        // TODO: consider two 7 bytes operations
        int l0 = getInt(left, 0);
        int l1 = getInt(left, 1);
        int l2 = getInt(left, 2);
        int l3 = getInt(left, 3);

        int r0 = getInt(right, 0);
        int r1 = getInt(right, 1);
        int r2 = getInt(right, 2);
        int r3 = getInt(right, 3);

        long intermediateResult;
        intermediateResult = (l0 & LONG_MASK) + (r0 & LONG_MASK);

        int z0 = (int) intermediateResult;

        intermediateResult = (l1 & LONG_MASK) + (r1 & LONG_MASK) + (intermediateResult >>> 32);

        int z1 = (int) intermediateResult;

        intermediateResult = (l2 & LONG_MASK) + (r2 & LONG_MASK) + (intermediateResult >>> 32);

        int z2 = (int) intermediateResult;

        intermediateResult = (l3 & LONG_MASK) + (r3 & LONG_MASK) + (intermediateResult >>> 32);

        int z3 = (int) intermediateResult & (~SIGN_INT_MASK);

        pack(result, z0, z1, z2, z3, resultNegative);

        return intermediateResult >> 31;
    }
295016
public void resetLimits() {
        maxLength = Long.MAX_VALUE;
        timeoutMs = Long.MAX_VALUE;
        maxRateBytesPerMs = Long.MAX_VALUE;
    }
105306
protected function offsetLimit()
    {
        if ($this->limit != 0 || $this->offset != 0)
            $this->documents = array_slice($this->documents, $this->offset, $this->limit);
    }
7935
private void discardIdleConnections() {
        List<Connection<CL>> connections = Lists.newArrayList();
        availableConnections.drainTo(connections);
        activeCount.addAndGet(-connections.size());

        for (Connection<CL> connection : connections) {
            try {
                closedConnections.incrementAndGet();
                connection.close(); // This is usually an async operation
            }
            catch (Throwable t) {
                // TODO
            }
        }
    }