function scan_tree(s, tree, max_code)
	//    deflate_state *s;
	//    ct_data *tree;   /* the tree to be scanned */
	//    int 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*2 + 1]/*.Len*/; /* 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)*2 + 1]/*.Len*/ = 0xffff; /* guard */
	
	  for (n = 0; n <= max_code; n++) {
	    curlen = nextlen;
	    nextlen = tree[(n+1)*2 + 1]/*.Len*/;
	
	    if (++count < max_count && curlen === nextlen) {
	      continue;
	
	    } else if (count < min_count) {
	      s.bl_tree[curlen * 2]/*.Freq*/ += count;
	
	    } else if (curlen !== 0) {
	
	      if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }
	      s.bl_tree[REP_3_6*2]/*.Freq*/++;
	
	    } else if (count <= 10) {
	      s.bl_tree[REPZ_3_10*2]/*.Freq*/++;
	
	    } else {
	      s.bl_tree[REPZ_11_138*2]/*.Freq*/++;
	    }
	
	    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;
	    }
	  }
	}
/* ===========================================================================
	 * Scan a literal or distance tree to determine the frequencies of the codes
	 * in the bit length tree.
	 */
Scan a literal or distance tree to determine the frequencies of the codes
in the bit length tree.
Scan a literal or distance tree to determine the frequencies of the codes in the bit length tree .
function scan_tree(s, tree, max_code)
	{
	  var n;                     
	  var prevlen = -1;          
	  var curlen;                
	  var nextlen = tree[0*2 + 1]; 
	  var count = 0;             
	  var max_count = 7;         
	  var min_count = 4;         
	  if (nextlen === 0) {
	    max_count = 138;
	    min_count = 3;
	  }
	  tree[(max_code+1)*2 + 1] = 0xffff; 
	  for (n = 0; n <= max_code; n++) {
	    curlen = nextlen;
	    nextlen = tree[(n+1)*2 + 1];
	    if (++count < max_count && curlen === nextlen) {
	      continue;
	    } else if (count < min_count) {
	      s.bl_tree[curlen * 2] += count;
	    } else if (curlen !== 0) {
	      if (curlen !== prevlen) { s.bl_tree[curlen * 2]++; }
	      s.bl_tree[REP_3_6*2]++;
	    } else if (count <= 10) {
	      s.bl_tree[REPZ_3_10*2]++;
	    } else {
	      s.bl_tree[REPZ_11_138*2]++;
	    }
	    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;
	    }
	  }
	}
function scan_tree ( s , tree , max_code ) { var n ; var prevlen = - 1 ; var curlen ; var nextlen = tree [ 0 * 2 + 1 ] ; var count = 0 ; var max_count = 7 ; var min_count = 4 ; if ( nextlen === 0 ) { max_count = 138 ; min_count = 3 ; } tree [ ( max_code + 1 ) * 2 + 1 ] = 0xffff ; for ( n = 0 ; n <= max_code ; n ++ ) { curlen = nextlen ; nextlen = tree [ ( n + 1 ) * 2 + 1 ] ; if ( ++ count < max_count && curlen === nextlen ) { continue ; } else if ( count < min_count ) { s . bl_tree [ curlen * 2 ] += count ; } else if ( curlen !== 0 ) { if ( curlen !== prevlen ) { s . bl_tree [ curlen * 2 ] ++ ; } s . bl_tree [ REP_3_6 * 2 ] ++ ; } else if ( count <= 10 ) { s . bl_tree [ REPZ_3_10 * 2 ] ++ ; } else { s . bl_tree [ REPZ_11_138 * 2 ] ++ ; } 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 ; } } }
Scan a literal or distance tree to determine the frequencies of the codes
 in the bit length tree.
Scan a literal or distance tree to determine the frequencies of the codes in the bit length tree .
//    deflate_state *s; //    ct_data *tree;   /* the tree to be scanned */ //    int max_code;    /* and its largest code of non zero frequency */ /* iterates over all tree elements */ /* last emitted length */ /* length of current code */ /*.Len*/ /* length of next code */ /* repeat count of the current code */ /* max repeat count */ /* min repeat count */ /*.Len*/ /* guard */ /*.Len*/ /*.Freq*/ /*.Freq*/ /*.Freq*/ /*.Freq*/ /*.Freq*/