code: function _endBatch() {
          --_batch;
          _cometd._debug('Ending batch, depth', _batch);
          if (_batch < 0) {
              throw 'Calls to startBatch() and endBatch() are not paired';
          }
  
          if (_batch === 0 && !_isDisconnected() && !_internalBatch) {
              _flushBatch();
          }
      }
docs: Ends the batch of messages to be sent in a single request,
  optionally sending messages present in the message queue depending
  on the given argument.
  @see #_startBatch()