function deflate_stored(s, flush) {
  /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
   * to pending_buf_size, and each stored block has a 5 byte header:
   */ let max_block_size = 65535;
  if (max_block_size > s.pending_buf_size - 5) {
    max_block_size = s.pending_buf_size - 5;
  }
  /* Copy as much as possible from input to output: */ for (;;) {
    /* Fill the window as much as possible: */ if (s.lookahead <= 1) {
      //Assert(s->strstart < s->w_size+MAX_DIST(s) ||
      //  s->block_start >= (long)s->w_size, "slide too late");
      //      if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||
      //        s.block_start >= s.w_size)) {
      //        throw  new Error("slide too late");
      //      }
      fill_window(s);
      if (s.lookahead === 0 && flush === STATUS.Z_NO_FLUSH) {
        return BS_NEED_MORE;
      }
      if (s.lookahead === 0) {
        break;
      }
      /* flush the current block */
    }
    //Assert(s->block_start >= 0L, "block gone");
    //    if (s.block_start < 0) throw new Error("block gone");
    s.strstart += s.lookahead;
    s.lookahead = 0;
    /* Emit a stored block if pending_buf will be full: */ let max_start =
      s.block_start + max_block_size;
    if (s.strstart === 0 || s.strstart >= max_start) {
      /* strstart == 0 is possible when wraparound on 16-bit machine */ s
        .lookahead = s.strstart - max_start;
      s.strstart = max_start;
      /*** FLUSH_BLOCK(s, 0); ***/ flush_block_only(s, false);
      if (s.strm.avail_out === 0) {
        return BS_NEED_MORE;
      }
      /***/
    }
    /* Flush if we may have to slide, otherwise block_start may become
     * negative and the data will be gone:
     */ if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) {
      /*** 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.strstart > s.block_start) {
    /*** FLUSH_BLOCK(s, 0); ***/ flush_block_only(s, false);
    if (s.strm.avail_out === 0) {
      return BS_NEED_MORE;
    }
    /***/
  }
  return BS_NEED_MORE;
}
/* ===========================================================================
 * Copy without compression as much as possible from the input stream, return
 * the current block state.
 * This function does not insert new strings in the dictionary since
 * uncompressible data is probably not useful. This function is used
 * only for the level=0 compression option.
 * NOTE: this function should be optimized to avoid extra copying from
 * window to pending_buf.
 */
Copy without compression as much as possible from the input stream, return
the current block state.
This function does not insert new strings in the dictionary since
uncompressible data is probably not useful. This function is used
only for the level=0 compression option.
NOTE: this function should be optimized to avoid extra copying from
window to pending_buf.
Copy without compression as much as possible from the input stream return the current block state . This function does not insert new strings in the dictionary since uncompressible data is probably not useful . This function is used only for the level = 0 compression option . NOTE : this function should be optimized to avoid extra copying from window to pending_buf .
function deflate_stored(s, flush) {
   let max_block_size = 65535;
  if (max_block_size > s.pending_buf_size - 5) {
    max_block_size = s.pending_buf_size - 5;
  }
   for (;;) {
     if (s.lookahead <= 1) {
      fill_window(s);
      if (s.lookahead === 0 && flush === STATUS.Z_NO_FLUSH) {
        return BS_NEED_MORE;
      }
      if (s.lookahead === 0) {
        break;
      }
    }
    s.strstart += s.lookahead;
    s.lookahead = 0;
     let max_start =
      s.block_start + max_block_size;
    if (s.strstart === 0 || s.strstart >= max_start) {
       s
        .lookahead = s.strstart - max_start;
      s.strstart = max_start;
       flush_block_only(s, false);
      if (s.strm.avail_out === 0) {
        return BS_NEED_MORE;
      }
    }
     if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) {
       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.strstart > s.block_start) {
     flush_block_only(s, false);
    if (s.strm.avail_out === 0) {
      return BS_NEED_MORE;
    }
  }
  return BS_NEED_MORE;
}
function deflate_stored ( s , flush ) { let max_block_size = 65535 ; if ( max_block_size > s . pending_buf_size - 5 ) { max_block_size = s . pending_buf_size - 5 ; } for ( ; ; ) { if ( s . lookahead <= 1 ) { fill_window ( s ) ; if ( s . lookahead === 0 && flush === STATUS . Z_NO_FLUSH ) { return BS_NEED_MORE ; } if ( s . lookahead === 0 ) { break ; } } s . strstart += s . lookahead ; s . lookahead = 0 ; let max_start = s . block_start + max_block_size ; if ( s . strstart === 0 || s . strstart >= max_start ) { s . lookahead = s . strstart - max_start ; s . strstart = max_start ; flush_block_only ( s , false ) ; if ( s . strm . avail_out === 0 ) { return BS_NEED_MORE ; } } if ( s . strstart - s . block_start >= s . w_size - MIN_LOOKAHEAD ) { 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 . strstart > s . block_start ) { flush_block_only ( s , false ) ; if ( s . strm . avail_out === 0 ) { return BS_NEED_MORE ; } } return BS_NEED_MORE ; }
Copy without compression as much as possible from the input stream, return
 the current block state.
Copy without compression as much as possible from the input stream return the current block state .
/* Stored blocks are limited to 0xffff bytes, pending_buf is limited
   * to pending_buf_size, and each stored block has a 5 byte header:
   */ /* Copy as much as possible from input to output: */ /* Fill the window as much as possible: */ //Assert(s->strstart < s->w_size+MAX_DIST(s) || //  s->block_start >= (long)s->w_size, "slide too late"); //      if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) || //        s.block_start >= s.w_size)) { //        throw  new Error("slide too late"); //      } /* flush the current block */ //Assert(s->block_start >= 0L, "block gone"); //    if (s.block_start < 0) throw new Error("block gone"); /* Emit a stored block if pending_buf will be full: */ /* strstart == 0 is possible when wraparound on 16-bit machine */ /*** FLUSH_BLOCK(s, 0); ***/ /***/ /* Flush if we may have to slide, otherwise block_start may become
     * negative and the data will be gone:
     */ /*** FLUSH_BLOCK(s, 0); ***/ /***/ /*** FLUSH_BLOCK(s, 1); ***/ /***/ /*** FLUSH_BLOCK(s, 0); ***/ /***/