function deflate_rle(s, flush) {
  let bflush; /* set if current block must be flushed */
  let prev; /* byte at distance one to match */
  let scan, strend; /* scan goes up to strend for length of run */
  let _win = s.window;
  for (;;) {
    /* Make sure that we always have enough lookahead, except
     * at the end of the input file. We need MAX_MATCH bytes
     * for the longest run, plus one for the unrolled loop.
     */ if (s.lookahead <= MAX_MATCH) {
      fill_window(s);
      if (s.lookahead <= MAX_MATCH && flush === STATUS.Z_NO_FLUSH) {
        return BS_NEED_MORE;
      }
      if (s.lookahead === 0) break; /* flush the current block */
    }
    /* See how many times the previous byte repeats */ s.match_length = 0;
    if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
      scan = s.strstart - 1;
      prev = _win[scan];
      if (
        prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]
      ) {
        strend = s.strstart + MAX_MATCH;
        do {
          /*jshint noempty:false*/
        } while (
          prev === _win[++scan] && prev === _win[++scan] &&
          prev === _win[++scan] && prev === _win[++scan] &&
          prev === _win[++scan] && prev === _win[++scan] &&
          prev === _win[++scan] && prev === _win[++scan] && scan < strend
        );
        s.match_length = MAX_MATCH - (strend - scan);
        if (s.match_length > s.lookahead) {
          s.match_length = s.lookahead;
        }
      }
      //Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
    }
    /* Emit match if have run of MIN_MATCH or longer, else emit literal */ if (
      s.match_length >= MIN_MATCH
    ) {
      //check_match(s, s.strstart, s.strstart - 1, s.match_length);
      /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/ bflush =
        trees._tr_tally(s, 1, s.match_length - MIN_MATCH);
      s.lookahead -= s.match_length;
      s.strstart += s.match_length;
      s.match_length = 0;
    } else {
      /* No match, output a literal byte */
      //Tracevv((stderr,"%c", s->window[s->strstart]));
      /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/ bflush = trees
        ._tr_tally(s, 0, s.window[s.strstart]);
      s.lookahead--;
      s.strstart++;
    }
    if (bflush) {
      /*** FLUSH_BLOCK(s, 0); ***/ flush_block_only(s, false);
      if (s.strm.avail_out === 0) {
        return BS_NEED_MORE;
      }
      /***/
    }
  }
  s.insert = 0;
  if (flush === STATUS.Z_FINISH) {
    /*** FLUSH_BLOCK(s, 1); ***/ flush_block_only(s, true);
    if (s.strm.avail_out === 0) {
      return BS_FINISH_STARTED;
    }
    /***/ return BS_FINISH_DONE;
  }
  if (s.last_lit) {
    /*** FLUSH_BLOCK(s, 0); ***/ flush_block_only(s, false);
    if (s.strm.avail_out === 0) {
      return BS_NEED_MORE;
    }
    /***/
  }
  return BS_BLOCK_DONE;
}
/* ===========================================================================
 * For Z_RLE, simply look for runs of bytes, generate matches only of distance
 * one.  Do not maintain a hash table.  (It will be regenerated if this run of
 * deflate switches away from Z_RLE.)
 */
For Z_RLE, simply look for runs of bytes, generate matches only of distance
one.  Do not maintain a hash table.  (It will be regenerated if this run of
deflate switches away from Z_RLE.)
For Z_RLE simply look for runs of bytes generate matches only of distance one . Do not maintain a hash table . ( It will be regenerated if this run of deflate switches away from Z_RLE . )
function deflate_rle(s, flush) {
  let bflush; 
  let prev; 
  let scan, strend; 
  let _win = s.window;
  for (;;) {
     if (s.lookahead <= MAX_MATCH) {
      fill_window(s);
      if (s.lookahead <= MAX_MATCH && flush === STATUS.Z_NO_FLUSH) {
        return BS_NEED_MORE;
      }
      if (s.lookahead === 0) break; 
    }
     s.match_length = 0;
    if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
      scan = s.strstart - 1;
      prev = _win[scan];
      if (
        prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]
      ) {
        strend = s.strstart + MAX_MATCH;
        do {
        } while (
          prev === _win[++scan] && prev === _win[++scan] &&
          prev === _win[++scan] && prev === _win[++scan] &&
          prev === _win[++scan] && prev === _win[++scan] &&
          prev === _win[++scan] && prev === _win[++scan] && scan < strend
        );
        s.match_length = MAX_MATCH - (strend - scan);
        if (s.match_length > s.lookahead) {
          s.match_length = s.lookahead;
        }
      }
    }
     if (
      s.match_length >= MIN_MATCH
    ) {
       bflush =
        trees._tr_tally(s, 1, s.match_length - MIN_MATCH);
      s.lookahead -= s.match_length;
      s.strstart += s.match_length;
      s.match_length = 0;
    } else {
       bflush = trees
        ._tr_tally(s, 0, s.window[s.strstart]);
      s.lookahead--;
      s.strstart++;
    }
    if (bflush) {
       flush_block_only(s, false);
      if (s.strm.avail_out === 0) {
        return BS_NEED_MORE;
      }
    }
  }
  s.insert = 0;
  if (flush === STATUS.Z_FINISH) {
     flush_block_only(s, true);
    if (s.strm.avail_out === 0) {
      return BS_FINISH_STARTED;
    }
     return BS_FINISH_DONE;
  }
  if (s.last_lit) {
     flush_block_only(s, false);
    if (s.strm.avail_out === 0) {
      return BS_NEED_MORE;
    }
  }
  return BS_BLOCK_DONE;
}
function deflate_rle ( s , flush ) { let bflush ; let prev ; let scan , strend ; let _win = s . window ; for ( ; ; ) { if ( s . lookahead <= MAX_MATCH ) { fill_window ( s ) ; if ( s . lookahead <= MAX_MATCH && flush === STATUS . Z_NO_FLUSH ) { return BS_NEED_MORE ; } if ( s . lookahead === 0 ) break ; } s . match_length = 0 ; if ( s . lookahead >= MIN_MATCH && s . strstart > 0 ) { scan = s . strstart - 1 ; prev = _win [ scan ] ; if ( prev === _win [ ++ scan ] && prev === _win [ ++ scan ] && prev === _win [ ++ scan ] ) { strend = s . strstart + MAX_MATCH ; do { } while ( prev === _win [ ++ scan ] && prev === _win [ ++ scan ] && prev === _win [ ++ scan ] && prev === _win [ ++ scan ] && prev === _win [ ++ scan ] && prev === _win [ ++ scan ] && prev === _win [ ++ scan ] && prev === _win [ ++ scan ] && scan < strend ) ; s . match_length = MAX_MATCH - ( strend - scan ) ; if ( s . match_length > s . lookahead ) { s . match_length = s . lookahead ; } } } if ( s . match_length >= MIN_MATCH ) { bflush = trees . _tr_tally ( s , 1 , s . match_length - MIN_MATCH ) ; s . lookahead -= s . match_length ; s . strstart += s . match_length ; s . match_length = 0 ; } else { bflush = trees . _tr_tally ( s , 0 , s . window [ s . strstart ] ) ; s . lookahead -- ; s . strstart ++ ; } if ( bflush ) { flush_block_only ( s , false ) ; if ( s . strm . avail_out === 0 ) { return BS_NEED_MORE ; } } } s . insert = 0 ; if ( flush === STATUS . Z_FINISH ) { flush_block_only ( s , true ) ; if ( s . strm . avail_out === 0 ) { return BS_FINISH_STARTED ; } return BS_FINISH_DONE ; } if ( s . last_lit ) { flush_block_only ( s , false ) ; if ( s . strm . avail_out === 0 ) { return BS_NEED_MORE ; } } return BS_BLOCK_DONE ; }
For Z_RLE, simply look for runs of bytes, generate matches only of distance
 one.
For Z_RLE simply look for runs of bytes generate matches only of distance one .
/* set if current block must be flushed */ /* byte at distance one to match */ /* scan goes up to strend for length of run */ /* Make sure that we always have enough lookahead, except
     * at the end of the input file. We need MAX_MATCH bytes
     * for the longest run, plus one for the unrolled loop.
     */ /* flush the current block */ /* See how many times the previous byte repeats */ /*jshint noempty:false*/ //Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); /* Emit match if have run of MIN_MATCH or longer, else emit literal */ //check_match(s, s.strstart, s.strstart - 1, s.match_length); /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/ /* No match, output a literal byte */ //Tracevv((stderr,"%c", s->window[s->strstart])); /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/ /*** FLUSH_BLOCK(s, 0); ***/ /***/ /*** FLUSH_BLOCK(s, 1); ***/ /***/ /*** FLUSH_BLOCK(s, 0); ***/ /***/