prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
function stem(tree, depth) {
  // First we break out the tree into a complete list of root to leaf paths
  var paths = rootToLeaf(tree);
  var stemmedRevs;

  var result;
  for (var i = 0, len = paths.length; i < len; i++) {
    // Then for each path, we cut off the start of the path based on the
    // `depth` to stem to, and generate a new set of flat trees
    var path = paths[i];
    var stemmed = path.ids;
    var node;
    if (stemmed.length > depth) {
      // only do the stemming work if we actually need to stem
      if (!stemmedRevs) {
        stemmedRevs = {}; // avoid allocating this object unnecessarily
      }
      var numStemmed = stemmed.length - depth;
      node = {
        pos: path.pos + numStemmed,
        ids: pathToTree(stemmed, numStemmed)
      };

      for (var s = 0; s < numStemmed; s++) {
        var rev = (path.pos + s) + '-' + stemmed[s].id;
        stemmedRevs[rev] = true;
      }
    } else { // no need to actually stem
      node = {
        pos: path.pos,
        ids: pathToTree(stemmed, 0)
      };
    }

    // Then we remerge all those flat trees together, ensuring that we dont
    // connect trees that would go beyond the depth limit
    if (result) {
      result = doMerge(result, node, true).tree;
    } else {
      result = [node];
    }
  }

  // this is memory-heavy per Chrome profiler, avoid unless we actually stemmed
  if (stemmedRevs) {
    traverseRevTree(result, function (isLeaf, pos, revHash) {
      // some revisions may have been removed in a branch but not in another
      delete stemmedRevs[pos + '-' + revHash];
    });
  }

  return {
    tree: result,
    revs: stemmedRevs ? Object.keys(stemmedRevs) : []
  };
}
function stem(tree, depth) {
  // First we break out the tree into a complete list of root to leaf paths
  var paths = rootToLeaf(tree);
  var stemmedRevs;

  var result;
  for (var i = 0, len = paths.length; i < len; i++) {
    // Then for each path, we cut off the start of the path based on the
    // `depth` to stem to, and generate a new set of flat trees
    var path = paths[i];
    var stemmed = path.ids;
    var node;
    if (stemmed.length > depth) {
      // only do the stemming work if we actually need to stem
      if (!stemmedRevs) {
        stemmedRevs = {}; // avoid allocating this object unnecessarily
      }
      var numStemmed = stemmed.length - depth;
      node = {
        pos: path.pos + numStemmed,
        ids: pathToTree(stemmed, numStemmed)
      };

      for (var s = 0; s < numStemmed; s++) {
        var rev = (path.pos + s) + '-' + stemmed[s].id;
        stemmedRevs[rev] = true;
      }
    } else { // no need to actually stem
      node = {
        pos: path.pos,
        ids: pathToTree(stemmed, 0)
      };
    }

    // Then we remerge all those flat trees together, ensuring that we dont
    // connect trees that would go beyond the depth limit
    if (result) {
      result = doMerge(result, node, true).tree;
    } else {
      result = [node];
    }
  }

  // this is memory-heavy per Chrome profiler, avoid unless we actually stemmed
  if (stemmedRevs) {
    traverseRevTree(result, function (isLeaf, pos, revHash) {
      // some revisions may have been removed in a branch but not in another
      delete stemmedRevs[pos + '-' + revHash];
    });
  }

  return {
    tree: result,
    revs: stemmedRevs ? Object.keys(stemmedRevs) : []
  };
}
function stem ( tree , depth ) { // First we break out the tree into a complete list of root to leaf paths var paths = rootToLeaf ( tree ) ; var stemmedRevs ; var result ; for ( var i = 0 , len = paths . length ; i < len ; i ++ ) { // Then for each path, we cut off the start of the path based on the // `depth` to stem to, and generate a new set of flat trees var path = paths [ i ] ; var stemmed = path . ids ; var node ; if ( stemmed . length > depth ) { // only do the stemming work if we actually need to stem if ( ! stemmedRevs ) { stemmedRevs = { } ; // avoid allocating this object unnecessarily } var numStemmed = stemmed . length - depth ; node = { pos : path . pos + numStemmed , ids : pathToTree ( stemmed , numStemmed ) } ; for ( var s = 0 ; s < numStemmed ; s ++ ) { var rev = ( path . pos + s ) + '-' + stemmed [ s ] . id ; stemmedRevs [ rev ] = true ; } } else { // no need to actually stem node = { pos : path . pos , ids : pathToTree ( stemmed , 0 ) } ; } // Then we remerge all those flat trees together, ensuring that we dont // connect trees that would go beyond the depth limit if ( result ) { result = doMerge ( result , node , true ) . tree ; } else { result = [ node ] ; } } // this is memory-heavy per Chrome profiler, avoid unless we actually stemmed if ( stemmedRevs ) { traverseRevTree ( result , function ( isLeaf , pos , revHash ) { // some revisions may have been removed in a branch but not in another delete stemmedRevs [ pos + '-' + revHash ] ; } ) ; } return { tree : result , revs : stemmedRevs ? Object . keys ( stemmedRevs ) : [ ] } ; }
To ensure we dont grow the revision tree infinitely, we stem old revisions
To ensure we dont grow the revision tree infinitely we stem old revisions