function updatewindow(strm, src, end, copy) {
  let dist;
  let state = strm.state;
  /* if it hasn't been done already, allocate space for the window */ if (
    state.window === null
  ) {
    state.wsize = 1 << state.wbits;
    state.wnext = 0;
    state.whave = 0;
    state.window = new Uint8Array(state.wsize);
  }
  /* copy state->wsize or less output bytes into the circular window */ if (
    copy >= state.wsize
  ) {
    state.window.set(src.subarray(end - state.wsize, end), 0);
    state.wnext = 0;
    state.whave = state.wsize;
  } else {
    dist = state.wsize - state.wnext;
    if (dist > copy) {
      dist = copy;
    }
    //zmemcpy(state->window + state->wnext, end - copy, dist);
    state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);
    copy -= dist;
    if (copy) {
      //zmemcpy(state->window, end - copy, copy);
      state.window.set(src.subarray(end - copy, end), 0);
      state.wnext = copy;
      state.whave = state.wsize;
    } else {
      state.wnext += dist;
      if (state.wnext === state.wsize) state.wnext = 0;
      if (state.whave < state.wsize) state.whave += dist;
    }
  }
  return 0;
}
/*
 Update the window with the last wsize (normally 32K) bytes written before
 returning.  If window does not exist yet, create it.  This is only called
 when a window is already in use, or when output has been written during this
 inflate call, but the end of the deflate stream has not been reached yet.
 It is also called to create a window for dictionary data when a dictionary
 is loaded.

 Providing output buffers larger than 32K to inflate() should provide a speed
 advantage, since only the last 32K of output is copied to the sliding window
 upon return from inflate(), and since all distances after the first 32K of
 output will fall in the output data, making match copies simpler and faster.
 The advantage may be dependent on the size of the processor's data caches.
 */
Update the window with the last wsize (normally 32K) bytes written before
returning.  If window does not exist yet, create it.  This is only called
when a window is already in use, or when output has been written during this
inflate call, but the end of the deflate stream has not been reached yet.
It is also called to create a window for dictionary data when a dictionary
is loaded.

Providing output buffers larger than 32K to inflate() should provide a speed
advantage, since only the last 32K of output is copied to the sliding window
upon return from inflate(), and since all distances after the first 32K of
output will fall in the output data, making match copies simpler and faster.
The advantage may be dependent on the size of the processor's data caches.
Update the window with the last wsize ( normally 32K ) bytes written before returning . If window does not exist yet create it . This is only called when a window is already in use or when output has been written during this inflate call but the end of the deflate stream has not been reached yet . It is also called to create a window for dictionary data when a dictionary is loaded . Providing output buffers larger than 32K to inflate () should provide a speed advantage since only the last 32K of output is copied to the sliding window upon return from inflate () and since all distances after the first 32K of output will fall in the output data making match copies simpler and faster . The advantage may be dependent on the size of the processor ' s data caches .
function updatewindow(strm, src, end, copy) {
  let dist;
  let state = strm.state;
   if (
    state.window === null
  ) {
    state.wsize = 1 << state.wbits;
    state.wnext = 0;
    state.whave = 0;
    state.window = new Uint8Array(state.wsize);
  }
   if (
    copy >= state.wsize
  ) {
    state.window.set(src.subarray(end - state.wsize, end), 0);
    state.wnext = 0;
    state.whave = state.wsize;
  } else {
    dist = state.wsize - state.wnext;
    if (dist > copy) {
      dist = copy;
    }
    state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);
    copy -= dist;
    if (copy) {
      state.window.set(src.subarray(end - copy, end), 0);
      state.wnext = copy;
      state.whave = state.wsize;
    } else {
      state.wnext += dist;
      if (state.wnext === state.wsize) state.wnext = 0;
      if (state.whave < state.wsize) state.whave += dist;
    }
  }
  return 0;
}
function updatewindow ( strm , src , end , copy ) { let dist ; let state = strm . state ; if ( state . window === null ) { state . wsize = 1 << state . wbits ; state . wnext = 0 ; state . whave = 0 ; state . window = new Uint8Array ( state . wsize ) ; } if ( copy >= state . wsize ) { state . window . set ( src . subarray ( end - state . wsize , end ) , 0 ) ; state . wnext = 0 ; state . whave = state . wsize ; } else { dist = state . wsize - state . wnext ; if ( dist > copy ) { dist = copy ; } state . window . set ( src . subarray ( end - copy , end - copy + dist ) , state . wnext ) ; copy -= dist ; if ( copy ) { state . window . set ( src . subarray ( end - copy , end ) , 0 ) ; state . wnext = copy ; state . whave = state . wsize ; } else { state . wnext += dist ; if ( state . wnext === state . wsize ) state . wnext = 0 ; if ( state . whave < state . wsize ) state . whave += dist ; } } return 0 ; }
Update the window with the last wsize (normally 32K) bytes written before
returning.
Update the window with the last wsize ( normally 32K ) bytes written before returning .
/* if it hasn't been done already, allocate space for the window */ /* copy state->wsize or less output bytes into the circular window */ //zmemcpy(state->window + state->wnext, end - copy, dist); //zmemcpy(state->window, end - copy, copy);