prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
function doNextCompaction(self) {
  var task = self._compactionQueue[0];
  var opts = task.opts;
  var callback = task.callback;
  self.get('_local/compaction').catch(function () {
    return false;
  }).then(function (doc) {
    if (doc && doc.last_seq) {
      opts.last_seq = doc.last_seq;
    }
    self._compact(opts, function (err, res) {
      /* istanbul ignore if */
      if (err) {
        callback(err);
      } else {
        callback(null, res);
      }
      pouchdbUtils.nextTick(function () {
        self._compactionQueue.shift();
        if (self._compactionQueue.length) {
          doNextCompaction(self);
        }
      });
    });
  });
}
function doNextCompaction(self) {
  var task = self._compactionQueue[0];
  var opts = task.opts;
  var callback = task.callback;
  self.get('_local/compaction').catch(function () {
    return false;
  }).then(function (doc) {
    if (doc && doc.last_seq) {
      opts.last_seq = doc.last_seq;
    }
    self._compact(opts, function (err, res) {
      /* istanbul ignore if */
      if (err) {
        callback(err);
      } else {
        callback(null, res);
      }
      pouchdbUtils.nextTick(function () {
        self._compactionQueue.shift();
        if (self._compactionQueue.length) {
          doNextCompaction(self);
        }
      });
    });
  });
}
function doNextCompaction ( self ) { var task = self . _compactionQueue [ 0 ] ; var opts = task . opts ; var callback = task . callback ; self . get ( '_local/compaction' ) . catch ( function ( ) { return false ; } ) . then ( function ( doc ) { if ( doc && doc . last_seq ) { opts . last_seq = doc . last_seq ; } self . _compact ( opts , function ( err , res ) { /* istanbul ignore if */ if ( err ) { callback ( err ) ; } else { callback ( null , res ) ; } pouchdbUtils . nextTick ( function ( ) { self . _compactionQueue . shift ( ) ; if ( self . _compactionQueue . length ) { doNextCompaction ( self ) ; } } ) ; } ) ; } ) ; }
all compaction is done in a queue, to avoid attaching too many listeners at once
all compaction is done in a queue to avoid attaching too many listeners at once