function fill_window(s) {
	  var _w_size = s.w_size;
	  var p, n, m, more, str;
	
	  //Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
	
	  do {
	    more = s.window_size - s.lookahead - s.strstart;
	
	    // JS ints have 32 bit, block below not needed
	    /* Deal with !@#$% 64K limit: */
	    //if (sizeof(int) <= 2) {
	    //    if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
	    //        more = wsize;
	    //
	    //  } else if (more == (unsigned)(-1)) {
	    //        /* Very unlikely, but possible on 16 bit machine if
	    //         * strstart == 0 && lookahead == 1 (input done a byte at time)
	    //         */
	    //        more--;
	    //    }
	    //}
	
	
	    /* If the window is almost full and there is insufficient lookahead,
	     * move the upper half to the lower one to make room in the upper half.
	     */
	    if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
	
	      utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
	      s.match_start -= _w_size;
	      s.strstart -= _w_size;
	      /* we now have strstart >= MAX_DIST */
	      s.block_start -= _w_size;
	
	      /* Slide the hash table (could be avoided with 32 bit values
	       at the expense of memory usage). We slide even when level == 0
	       to keep the hash table consistent if we switch back to level > 0
	       later. (Using level 0 permanently is not an optimal usage of
	       zlib, so we don't care about this pathological case.)
	       */
	
	      n = s.hash_size;
	      p = n;
	      do {
	        m = s.head[--p];
	        s.head[p] = (m >= _w_size ? m - _w_size : 0);
	      } while (--n);
	
	      n = _w_size;
	      p = n;
	      do {
	        m = s.prev[--p];
	        s.prev[p] = (m >= _w_size ? m - _w_size : 0);
	        /* If n is not on any hash chain, prev[n] is garbage but
	         * its value will never be used.
	         */
	      } while (--n);
	
	      more += _w_size;
	    }
	    if (s.strm.avail_in === 0) {
	      break;
	    }
	
	    /* If there was no sliding:
	     *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
	     *    more == window_size - lookahead - strstart
	     * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
	     * => more >= window_size - 2*WSIZE + 2
	     * In the BIG_MEM or MMAP case (not yet supported),
	     *   window_size == input_size + MIN_LOOKAHEAD  &&
	     *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
	     * Otherwise, window_size == 2*WSIZE so more >= 2.
	     * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
	     */
	    //Assert(more >= 2, "more < 2");
	    n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
	    s.lookahead += n;
	
	    /* Initialize the hash value now that we have some input: */
	    if (s.lookahead + s.insert >= MIN_MATCH) {
	      str = s.strstart - s.insert;
	      s.ins_h = s.window[str];
	
	      /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */
	      s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;
	//#if MIN_MATCH != 3
	//        Call update_hash() MIN_MATCH-3 more times
	//#endif
	      while (s.insert) {
	        /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
	        s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH-1]) & s.hash_mask;
	
	        s.prev[str & s.w_mask] = s.head[s.ins_h];
	        s.head[s.ins_h] = str;
	        str++;
	        s.insert--;
	        if (s.lookahead + s.insert < MIN_MATCH) {
	          break;
	        }
	      }
	    }
	    /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
	     * but this is not important since only literal bytes will be emitted.
	     */
	
	  } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
	
	  /* If the WIN_INIT bytes after the end of the current data have never been
	   * written, then zero those bytes in order to avoid memory check reports of
	   * the use of uninitialized (or uninitialised as Julian writes) bytes by
	   * the longest match routines.  Update the high water mark for the next
	   * time through here.  WIN_INIT is set to MAX_MATCH since the longest match
	   * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
	   */
	//  if (s.high_water < s.window_size) {
	//    var curr = s.strstart + s.lookahead;
	//    var init = 0;
	//
	//    if (s.high_water < curr) {
	//      /* Previous high water mark below current data -- zero WIN_INIT
	//       * bytes or up to end of window, whichever is less.
	//       */
	//      init = s.window_size - curr;
	//      if (init > WIN_INIT)
	//        init = WIN_INIT;
	//      zmemzero(s->window + curr, (unsigned)init);
	//      s->high_water = curr + init;
	//    }
	//    else if (s->high_water < (ulg)curr + WIN_INIT) {
	//      /* High water mark at or above current data, but below current data
	//       * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
	//       * to end of window, whichever is less.
	//       */
	//      init = (ulg)curr + WIN_INIT - s->high_water;
	//      if (init > s->window_size - s->high_water)
	//        init = s->window_size - s->high_water;
	//      zmemzero(s->window + s->high_water, (unsigned)init);
	//      s->high_water += init;
	//    }
	//  }
	//
	//  Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
	//    "not enough room for search");
	}
/* ===========================================================================
	 * Fill the window when the lookahead becomes insufficient.
	 * Updates strstart and lookahead.
	 *
	 * IN assertion: lookahead < MIN_LOOKAHEAD
	 * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
	 *    At least one byte has been read, or avail_in == 0; reads are
	 *    performed for at least two bytes (required for the zip translate_eol
	 *    option -- not supported here).
	 */
Fill the window when the lookahead becomes insufficient.
Updates strstart and lookahead.

IN assertion: lookahead < MIN_LOOKAHEAD
OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
At least one byte has been read, or avail_in == 0; reads are
performed for at least two bytes (required for the zip translate_eol
option -- not supported here).
Fill the window when the lookahead becomes insufficient . Updates strstart and lookahead . IN assertion : lookahead < MIN_LOOKAHEAD OUT assertions : strstart < = window_size - MIN_LOOKAHEAD At least one byte has been read or avail_in == 0 ; reads are performed for at least two bytes ( required for the zip translate_eol option -- not supported here ) .
function fill_window(s) {
	  var _w_size = s.w_size;
	  var p, n, m, more, str;
	  do {
	    more = s.window_size - s.lookahead - s.strstart;
	      } else if (more == (unsigned)(-1)) {
	            /* Very unlikely, but possible on 16 bit machine if
	             * strstart == 0 && lookahead == 1 (input done a byte at time)
	             */
	            more--;
	        }
	    }
	    if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
	      utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
	      s.match_start -= _w_size;
	      s.strstart -= _w_size;
	      s.block_start -= _w_size;
	      n = s.hash_size;
	      p = n;
	      do {
	        m = s.head[--p];
	        s.head[p] = (m >= _w_size ? m - _w_size : 0);
	      } while (--n);
	      n = _w_size;
	      p = n;
	      do {
	        m = s.prev[--p];
	        s.prev[p] = (m >= _w_size ? m - _w_size : 0);
	      } while (--n);
	      more += _w_size;
	    }
	    if (s.strm.avail_in === 0) {
	      break;
	    }
	    Assert(more >= 2, "more < 2");
	    n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
	    s.lookahead += n;
	    if (s.lookahead + s.insert >= MIN_MATCH) {
	      str = s.strstart - s.insert;
	      s.ins_h = s.window[str];
	      s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;
	#if MIN_MATCH != 3
	        Call update_hash() MIN_MATCH-3 more times
	#endif
	      while (s.insert) {
	        s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH-1]) & s.hash_mask;
	        s.prev[str & s.w_mask] = s.head[s.ins_h];
	        s.head[s.ins_h] = str;
	        str++;
	        s.insert--;
	        if (s.lookahead + s.insert < MIN_MATCH) {
	          break;
	        }
	      }
	    }
	  } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
	  if (s.high_water < s.window_size) {
	    var curr = s.strstart + s.lookahead;
	    var init = 0;
	    if (s.high_water < curr) {
	      /* Previous high water mark below current data -- zero WIN_INIT
	       * bytes or up to end of window, whichever is less.
	       */
	      init = s.window_size - curr;
	      if (init > WIN_INIT)
	        init = WIN_INIT;
	      zmemzero(s->window + curr, (unsigned)init);
	      s->high_water = curr + init;
	    }
	    else if (s->high_water < (ulg)curr + WIN_INIT) {
	      /* High water mark at or above current data, but below current data
	       * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
	       * to end of window, whichever is less.
	       */
	      init = (ulg)curr + WIN_INIT - s->high_water;
	      if (init > s->window_size - s->high_water)
	        init = s->window_size - s->high_water;
	      zmemzero(s->window + s->high_water, (unsigned)init);
	      s->high_water += init;
	    }
	  }
	  Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
	    "not enough room for search");
	}
function fill_window ( s ) { var _w_size = s . w_size ; var p , n , m , more , str ; do { more = s . window_size - s . lookahead - s . strstart ; if ( s . strstart >= _w_size + ( _w_size - MIN_LOOKAHEAD ) ) { utils . arraySet ( s . window , s . window , _w_size , _w_size , 0 ) ; s . match_start -= _w_size ; s . strstart -= _w_size ; s . block_start -= _w_size ; n = s . hash_size ; p = n ; do { m = s . head [ -- p ] ; s . head [ p ] = ( m >= _w_size ? m - _w_size : 0 ) ; } while ( -- n ) ; n = _w_size ; p = n ; do { m = s . prev [ -- p ] ; s . prev [ p ] = ( m >= _w_size ? m - _w_size : 0 ) ; } while ( -- n ) ; more += _w_size ; } if ( s . strm . avail_in === 0 ) { break ; } n = read_buf ( s . strm , s . window , s . strstart + s . lookahead , more ) ; s . lookahead += n ; if ( s . lookahead + s . insert >= MIN_MATCH ) { str = s . strstart - s . insert ; s . ins_h = s . window [ str ] ; s . ins_h = ( ( s . ins_h << s . hash_shift ) ^ s . window [ str + 1 ] ) & s . hash_mask ; while ( s . insert ) { s . ins_h = ( ( s . ins_h << s . hash_shift ) ^ s . window [ str + MIN_MATCH - 1 ] ) & s . hash_mask ; s . prev [ str & s . w_mask ] = s . head [ s . ins_h ] ; s . head [ s . ins_h ] = str ; str ++ ; s . insert -- ; if ( s . lookahead + s . insert < MIN_MATCH ) { break ; } } } } while ( s . lookahead < MIN_LOOKAHEAD && s . strm . avail_in !== 0 ) ; }
Fill the window when the lookahead becomes insufficient.
Fill the window when the lookahead becomes insufficient .
//Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); // JS ints have 32 bit, block below not needed /* Deal with !@#$% 64K limit: */ //if (sizeof(int) <= 2) { //    if (more == 0 && s->strstart == 0 && s->lookahead == 0) { //        more = wsize; // //  } else if (more == (unsigned)(-1)) { //        /* Very unlikely, but possible on 16 bit machine if //         * strstart == 0 && lookahead == 1 (input done a byte at time) //         */ //        more--; //    } //} /* If the window is almost full and there is insufficient lookahead,
	     * move the upper half to the lower one to make room in the upper half.
	     */ /* we now have strstart >= MAX_DIST */ /* Slide the hash table (could be avoided with 32 bit values
	       at the expense of memory usage). We slide even when level == 0
	       to keep the hash table consistent if we switch back to level > 0
	       later. (Using level 0 permanently is not an optimal usage of
	       zlib, so we don't care about this pathological case.)
	       */ /* If n is not on any hash chain, prev[n] is garbage but
	         * its value will never be used.
	         */ /* If there was no sliding:
	     *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
	     *    more == window_size - lookahead - strstart
	     * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
	     * => more >= window_size - 2*WSIZE + 2
	     * In the BIG_MEM or MMAP case (not yet supported),
	     *   window_size == input_size + MIN_LOOKAHEAD  &&
	     *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
	     * Otherwise, window_size == 2*WSIZE so more >= 2.
	     * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
	     */ //Assert(more >= 2, "more < 2"); /* Initialize the hash value now that we have some input: */ /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */ //#if MIN_MATCH != 3 //        Call update_hash() MIN_MATCH-3 more times //#endif /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */ /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
	     * but this is not important since only literal bytes will be emitted.
	     */ /* If the WIN_INIT bytes after the end of the current data have never been
	   * written, then zero those bytes in order to avoid memory check reports of
	   * the use of uninitialized (or uninitialised as Julian writes) bytes by
	   * the longest match routines.  Update the high water mark for the next
	   * time through here.  WIN_INIT is set to MAX_MATCH since the longest match
	   * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
	   */ //  if (s.high_water < s.window_size) { //    var curr = s.strstart + s.lookahead; //    var init = 0; // //    if (s.high_water < curr) { //      /* Previous high water mark below current data -- zero WIN_INIT //       * bytes or up to end of window, whichever is less. //       */ //      init = s.window_size - curr; //      if (init > WIN_INIT) //        init = WIN_INIT; //      zmemzero(s->window + curr, (unsigned)init); //      s->high_water = curr + init; //    } //    else if (s->high_water < (ulg)curr + WIN_INIT) { //      /* High water mark at or above current data, but below current data //       * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up //       * to end of window, whichever is less. //       */ //      init = (ulg)curr + WIN_INIT - s->high_water; //      if (init > s->window_size - s->high_water) //        init = s->window_size - s->high_water; //      zmemzero(s->window + s->high_water, (unsigned)init); //      s->high_water += init; //    } //  } // //  Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, //    "not enough room for search");