code: function zip_scan_tree(tree, // the tree to be scanned
    max_code) {  // and its largest code of non zero frequency
    var n;			// iterates over all tree elements
    var prevlen = -1;		// last emitted length
    var curlen;			// length of current code
    var nextlen = tree[0].dl;	// length of next code
    var count = 0;		// repeat count of the current code
    var max_count = 7;		// max repeat count
    var min_count = 4;		// min repeat count
  
    if (nextlen == 0) {
      max_count = 138;
      min_count = 3;
    }
    tree[max_code + 1].dl = 0xffff; // guard
  
    for (n = 0; n <= max_code; n++) {
      curlen = nextlen;
      nextlen = tree[n + 1].dl;
      if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { zip_bl_tree[curlen].fc += count; } else if (curlen != 0) {
        if (curlen != prevlen) { zip_bl_tree[curlen].fc++; }
        zip_bl_tree[zip_REP_3_6].fc++;
      } else if (count <= 10) { zip_bl_tree[zip_REPZ_3_10].fc++; } else { zip_bl_tree[zip_REPZ_11_138].fc++; }
      count = 0; prevlen = curlen;
      if (nextlen == 0) {
        max_count = 138;
        min_count = 3;
      } else if (curlen == nextlen) {
        max_count = 6;
        min_count = 3;
      } else {
        max_count = 7;
        min_count = 4;
      }
    }
  }
docs: /* ==========================================================================
  Scan a literal or distance tree to determine the frequencies of the codes
  in the bit length tree. Updates opt_len to take into account the repeat
  counts. (The contribution of the bit length codes will be added later
  during the construction of bl_tree.)