(s, flush)
| 18721 | * window to pending_buf. |
| 18722 | */ |
| 18723 | function deflate_stored(s, flush) { |
| 18724 | /* Stored blocks are limited to 0xffff bytes, pending_buf is limited |
| 18725 | * to pending_buf_size, and each stored block has a 5 byte header: |
| 18726 | */ |
| 18727 | var max_block_size = 0xffff; |
| 18728 | |
| 18729 | if (max_block_size > s.pending_buf_size - 5) { |
| 18730 | max_block_size = s.pending_buf_size - 5; |
| 18731 | } |
| 18732 | |
| 18733 | /* Copy as much as possible from input to output: */ |
| 18734 | for (;;) { |
| 18735 | /* Fill the window as much as possible: */ |
| 18736 | if (s.lookahead <= 1) { |
| 18737 | |
| 18738 | //Assert(s->strstart < s->w_size+MAX_DIST(s) || |
| 18739 | // s->block_start >= (long)s->w_size, "slide too late"); |
| 18740 | // if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) || |
| 18741 | // s.block_start >= s.w_size)) { |
| 18742 | // throw new Error("slide too late"); |
| 18743 | // } |
| 18744 | |
| 18745 | fill_window(s); |
| 18746 | if (s.lookahead === 0 && flush === Z_NO_FLUSH) { |
| 18747 | return BS_NEED_MORE; |
| 18748 | } |
| 18749 | |
| 18750 | if (s.lookahead === 0) { |
| 18751 | break; |
| 18752 | } |
| 18753 | /* flush the current block */ |
| 18754 | } |
| 18755 | //Assert(s->block_start >= 0L, "block gone"); |
| 18756 | // if (s.block_start < 0) throw new Error("block gone"); |
| 18757 | |
| 18758 | s.strstart += s.lookahead; |
| 18759 | s.lookahead = 0; |
| 18760 | |
| 18761 | /* Emit a stored block if pending_buf will be full: */ |
| 18762 | var max_start = s.block_start + max_block_size; |
| 18763 | |
| 18764 | if (s.strstart === 0 || s.strstart >= max_start) { |
| 18765 | /* strstart == 0 is possible when wraparound on 16-bit machine */ |
| 18766 | s.lookahead = s.strstart - max_start; |
| 18767 | s.strstart = max_start; |
| 18768 | /*** FLUSH_BLOCK(s, 0); ***/ |
| 18769 | flush_block_only(s, false); |
| 18770 | if (s.strm.avail_out === 0) { |
| 18771 | return BS_NEED_MORE; |
| 18772 | } |
| 18773 | /***/ |
| 18774 | |
| 18775 | |
| 18776 | } |
| 18777 | /* Flush if we may have to slide, otherwise block_start may become |
| 18778 | * negative and the data will be gone: |
| 18779 | */ |
| 18780 | if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) { |
nothing calls this directly
no test coverage detected