prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
function parseDoc(doc, newEdits) {

  var nRevNum;
  var newRevId;
  var revInfo;
  var opts = {status: 'available'};
  if (doc._deleted) {
    opts.deleted = true;
  }

  if (newEdits) {
    if (!doc._id) {
      doc._id = pouchdbUtils.uuid();
    }
    newRevId = pouchdbUtils.uuid(32, 16).toLowerCase();
    if (doc._rev) {
      revInfo = parseRevisionInfo(doc._rev);
      if (revInfo.error) {
        return revInfo;
      }
      doc._rev_tree = [{
        pos: revInfo.prefix,
        ids: [revInfo.id, {status: 'missing'}, [[newRevId, opts, []]]]
      }];
      nRevNum = revInfo.prefix + 1;
    } else {
      doc._rev_tree = [{
        pos: 1,
        ids : [newRevId, opts, []]
      }];
      nRevNum = 1;
    }
  } else {
    if (doc._revisions) {
      doc._rev_tree = makeRevTreeFromRevisions(doc._revisions, opts);
      nRevNum = doc._revisions.start;
      newRevId = doc._revisions.ids[0];
    }
    if (!doc._rev_tree) {
      revInfo = parseRevisionInfo(doc._rev);
      if (revInfo.error) {
        return revInfo;
      }
      nRevNum = revInfo.prefix;
      newRevId = revInfo.id;
      doc._rev_tree = [{
        pos: nRevNum,
        ids: [newRevId, opts, []]
      }];
    }
  }

  pouchdbUtils.invalidIdError(doc._id);

  doc._rev = nRevNum + '-' + newRevId;

  var result = {metadata : {}, data : {}};
  for (var key in doc) {
    /* istanbul ignore else */
    if (Object.prototype.hasOwnProperty.call(doc, key)) {
      var specialKey = key[0] === '_';
      if (specialKey && !reservedWords[key]) {
        var error = pouchdbErrors.createError(pouchdbErrors.DOC_VALIDATION, key);
        error.message = pouchdbErrors.DOC_VALIDATION.message + ': ' + key;
        throw error;
      } else if (specialKey && !dataWords[key]) {
        result.metadata[key.slice(1)] = doc[key];
      } else {
        result.data[key] = doc[key];
      }
    }
  }
  return result;
}
function parseDoc(doc, newEdits) {

  var nRevNum;
  var newRevId;
  var revInfo;
  var opts = {status: 'available'};
  if (doc._deleted) {
    opts.deleted = true;
  }

  if (newEdits) {
    if (!doc._id) {
      doc._id = pouchdbUtils.uuid();
    }
    newRevId = pouchdbUtils.uuid(32, 16).toLowerCase();
    if (doc._rev) {
      revInfo = parseRevisionInfo(doc._rev);
      if (revInfo.error) {
        return revInfo;
      }
      doc._rev_tree = [{
        pos: revInfo.prefix,
        ids: [revInfo.id, {status: 'missing'}, [[newRevId, opts, []]]]
      }];
      nRevNum = revInfo.prefix + 1;
    } else {
      doc._rev_tree = [{
        pos: 1,
        ids : [newRevId, opts, []]
      }];
      nRevNum = 1;
    }
  } else {
    if (doc._revisions) {
      doc._rev_tree = makeRevTreeFromRevisions(doc._revisions, opts);
      nRevNum = doc._revisions.start;
      newRevId = doc._revisions.ids[0];
    }
    if (!doc._rev_tree) {
      revInfo = parseRevisionInfo(doc._rev);
      if (revInfo.error) {
        return revInfo;
      }
      nRevNum = revInfo.prefix;
      newRevId = revInfo.id;
      doc._rev_tree = [{
        pos: nRevNum,
        ids: [newRevId, opts, []]
      }];
    }
  }

  pouchdbUtils.invalidIdError(doc._id);

  doc._rev = nRevNum + '-' + newRevId;

  var result = {metadata : {}, data : {}};
  for (var key in doc) {
    /* istanbul ignore else */
    if (Object.prototype.hasOwnProperty.call(doc, key)) {
      var specialKey = key[0] === '_';
      if (specialKey && !reservedWords[key]) {
        var error = pouchdbErrors.createError(pouchdbErrors.DOC_VALIDATION, key);
        error.message = pouchdbErrors.DOC_VALIDATION.message + ': ' + key;
        throw error;
      } else if (specialKey && !dataWords[key]) {
        result.metadata[key.slice(1)] = doc[key];
      } else {
        result.data[key] = doc[key];
      }
    }
  }
  return result;
}
function parseDoc ( doc , newEdits ) { var nRevNum ; var newRevId ; var revInfo ; var opts = { status : 'available' } ; if ( doc . _deleted ) { opts . deleted = true ; } if ( newEdits ) { if ( ! doc . _id ) { doc . _id = pouchdbUtils . uuid ( ) ; } newRevId = pouchdbUtils . uuid ( 32 , 16 ) . toLowerCase ( ) ; if ( doc . _rev ) { revInfo = parseRevisionInfo ( doc . _rev ) ; if ( revInfo . error ) { return revInfo ; } doc . _rev_tree = [ { pos : revInfo . prefix , ids : [ revInfo . id , { status : 'missing' } , [ [ newRevId , opts , [ ] ] ] ] } ] ; nRevNum = revInfo . prefix + 1 ; } else { doc . _rev_tree = [ { pos : 1 , ids : [ newRevId , opts , [ ] ] } ] ; nRevNum = 1 ; } } else { if ( doc . _revisions ) { doc . _rev_tree = makeRevTreeFromRevisions ( doc . _revisions , opts ) ; nRevNum = doc . _revisions . start ; newRevId = doc . _revisions . ids [ 0 ] ; } if ( ! doc . _rev_tree ) { revInfo = parseRevisionInfo ( doc . _rev ) ; if ( revInfo . error ) { return revInfo ; } nRevNum = revInfo . prefix ; newRevId = revInfo . id ; doc . _rev_tree = [ { pos : nRevNum , ids : [ newRevId , opts , [ ] ] } ] ; } } pouchdbUtils . invalidIdError ( doc . _id ) ; doc . _rev = nRevNum + '-' + newRevId ; var result = { metadata : { } , data : { } } ; for ( var key in doc ) { /* istanbul ignore else */ if ( Object . prototype . hasOwnProperty . call ( doc , key ) ) { var specialKey = key [ 0 ] === '_' ; if ( specialKey && ! reservedWords [ key ] ) { var error = pouchdbErrors . createError ( pouchdbErrors . DOC_VALIDATION , key ) ; error . message = pouchdbErrors . DOC_VALIDATION . message + ': ' + key ; throw error ; } else if ( specialKey && ! dataWords [ key ] ) { result . metadata [ key . slice ( 1 ) ] = doc [ key ] ; } else { result . data [ key ] = doc [ key ] ; } } } return result ; }
Preprocess documents, parse their revisions, assign an id and a revision for new writes that are missing them, etc
Preprocess documents parse their revisions assign an id and a revision for new writes that are missing them etc