function send_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]; /* 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 */

  /* tree[max_code+1].Len = -1; */
  /* guard already set */
  if (nextlen === 0) {
    max_count = 138;
    min_count = 3;
  }

  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) {
      do {
        send_code(s, curlen, s.bl_tree);
      } while (--count !== 0);

    } else if (curlen !== 0) {
      if (curlen !== prevlen) {
        send_code(s, curlen, s.bl_tree);
        count--;
      }
      //Assert(count >= 3 && count <= 6, " 3_6?");
      send_code(s, REP_3_6, s.bl_tree);
      send_bits(s, count - 3, 2);

    } else if (count <= 10) {
      send_code(s, REPZ_3_10, s.bl_tree);
      send_bits(s, count - 3, 3);

    } else {
      send_code(s, REPZ_11_138, s.bl_tree);
      send_bits(s, count - 11, 7);
    }

    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;
    }
  }
}
/* ===========================================================================
 * Send a literal or distance tree in compressed form, using the codes in
 * bl_tree.
 */
Send a literal or distance tree in compressed form, using the codes in
bl_tree.
Send a literal or distance tree in compressed form using the codes in bl_tree .
function send_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;
  }
  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) {
      do {
        send_code(s, curlen, s.bl_tree);
      } while (--count !== 0);
    } else if (curlen !== 0) {
      if (curlen !== prevlen) {
        send_code(s, curlen, s.bl_tree);
        count--;
      }
      send_code(s, REP_3_6, s.bl_tree);
      send_bits(s, count - 3, 2);
    } else if (count <= 10) {
      send_code(s, REPZ_3_10, s.bl_tree);
      send_bits(s, count - 3, 3);
    } else {
      send_code(s, REPZ_11_138, s.bl_tree);
      send_bits(s, count - 11, 7);
    }
    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 send_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 ; } 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 ) { do { send_code ( s , curlen , s . bl_tree ) ; } while ( -- count !== 0 ) ; } else if ( curlen !== 0 ) { if ( curlen !== prevlen ) { send_code ( s , curlen , s . bl_tree ) ; count -- ; } send_code ( s , REP_3_6 , s . bl_tree ) ; send_bits ( s , count - 3 , 2 ) ; } else if ( count <= 10 ) { send_code ( s , REPZ_3_10 , s . bl_tree ) ; send_bits ( s , count - 3 , 3 ) ; } else { send_code ( s , REPZ_11_138 , s . bl_tree ) ; send_bits ( s , count - 11 , 7 ) ; } 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 ; } } }
Send a literal or distance tree in compressed form, using the codes in
 bl_tree.
Send a literal or distance tree in compressed form using the codes in bl_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 */ /* length of next code */ /* repeat count of the current code */ /* max repeat count */ /* min repeat count */ /* tree[max_code+1].Len = -1; */ /* guard already set */ /*.Len*/ //Assert(count >= 3 && count <= 6, " 3_6?");