code: function getDigestsToLastUsed(mainDoc, lastUsedDoc) {
    var result = {};
  
    // dedup by digest, use the most recent date
    Object.keys(mainDoc._attachments).forEach(function (attName) {
      var att = mainDoc._attachments[attName];
      var existing  = result[att.digest] || 0;
      result[att.digest] = Math.max(existing, lastUsedDoc.lastUsed[att.digest]);
    });
  
    return result;
  }
docs: Get a map of unique digests to when they were last used.