code: function prepareForDestruction(self) {
  
    var destructionListeners = self.constructor._destructionListeners;
  
    function onDestroyed() {
      self.removeListener('closed', onClosed);
      self.constructor.emit('destroyed', self.name);
    }
  
    function onConstructorDestroyed() {
      self.removeListener('destroyed', onDestroyed);
      self.removeListener('closed', onClosed);
      self.emit('destroyed');
    }
  
    function onClosed() {
      self.removeListener('destroyed', onDestroyed);
      destructionListeners.delete(self.name);
    }
  
    self.once('destroyed', onDestroyed);
    self.once('closed', onClosed);
  
    // in setup.js, the constructor is primed to listen for destroy events
    if (!destructionListeners.has(self.name)) {
      destructionListeners.set(self.name, []);
    }
    destructionListeners.get(self.name).push(onConstructorDestroyed);
  }
docs: OK, so here's the deal. Consider this code: var db1 = new PouchDB('foo'); var db2 = new PouchDB('foo'); db1.destroy(); ^ these two both need to emit 'destroyed' events, as well as the PouchDB constructor itself. So we have one db object (whichever one got destroy() called on it) responsible for emitting the initial event, which then gets emitted by the constructor, which then broadcasts it to any other dbs that may have been created with the same name.