index.js
function calculateTotalSize(mainDoc) {
  var digestsToSizes = {};

  // dedup by digest, since that's what Pouch does under the hood
  Object.keys(mainDoc._attachments).forEach(function (attName) {
    var att = mainDoc._attachments[attName];
    digestsToSizes[att.digest] = att.length;
  });

  var total = 0;
  Object.keys(digestsToSizes).forEach(function (digest) {
    total += digestsToSizes[digest];
  });
  return total;
}
function calculateTotalSize(mainDoc) {
  var digestsToSizes = {};

  // dedup by digest, since that's what Pouch does under the hood
  Object.keys(mainDoc._attachments).forEach(function (attName) {
    var att = mainDoc._attachments[attName];
    digestsToSizes[att.digest] = att.length;
  });

  var total = 0;
  Object.keys(digestsToSizes).forEach(function (digest) {
    total += digestsToSizes[digest];
  });
  return total;
}
function calculateTotalSize ( mainDoc ) { var digestsToSizes = { } ; // dedup by digest, since that's what Pouch does under the hood Object . keys ( mainDoc . _attachments ) . forEach ( function ( attName ) { var att = mainDoc . _attachments [ attName ] ; digestsToSizes [ att . digest ] = att . length ; } ) ; var total = 0 ; Object . keys ( digestsToSizes ) . forEach ( function ( digest ) { total += digestsToSizes [ digest ] ; } ) ; return total ; }
Get the total size of the LRU cache, taking duplicate digests into account
Get the total size of the LRU cache taking duplicate digests into account