(s, flush)
| 6631 | * window to pending_buf. |
| 6632 | */ |
| 6633 | function deflate_stored(s, flush) { |
| 6634 | /* Stored blocks are limited to 0xffff bytes, pending_buf is limited |
| 6635 | * to pending_buf_size, and each stored block has a 5 byte header: |
| 6636 | */ |
| 6637 | var max_block_size = 0xffff; |
| 6638 | |
| 6639 | if (max_block_size > s.pending_buf_size - 5) { |
| 6640 | max_block_size = s.pending_buf_size - 5; |
| 6641 | } |
| 6642 | |
| 6643 | /* Copy as much as possible from input to output: */ |
| 6644 | for (;;) { |
| 6645 | /* Fill the window as much as possible: */ |
| 6646 | if (s.lookahead <= 1) { |
| 6647 | |
| 6648 | //Assert(s->strstart < s->w_size+MAX_DIST(s) || |
| 6649 | // s->block_start >= (long)s->w_size, "slide too late"); |
| 6650 | // if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) || |
| 6651 | // s.block_start >= s.w_size)) { |
| 6652 | // throw new Error("slide too late"); |
| 6653 | // } |
| 6654 | |
| 6655 | fill_window(s); |
| 6656 | if (s.lookahead === 0 && flush === Z_NO_FLUSH) { |
| 6657 | return BS_NEED_MORE; |
| 6658 | } |
| 6659 | |
| 6660 | if (s.lookahead === 0) { |
| 6661 | break; |
| 6662 | } |
| 6663 | /* flush the current block */ |
| 6664 | } |
| 6665 | //Assert(s->block_start >= 0L, "block gone"); |
| 6666 | // if (s.block_start < 0) throw new Error("block gone"); |
| 6667 | |
| 6668 | s.strstart += s.lookahead; |
| 6669 | s.lookahead = 0; |
| 6670 | |
| 6671 | /* Emit a stored block if pending_buf will be full: */ |
| 6672 | var max_start = s.block_start + max_block_size; |
| 6673 | |
| 6674 | if (s.strstart === 0 || s.strstart >= max_start) { |
| 6675 | /* strstart == 0 is possible when wraparound on 16-bit machine */ |
| 6676 | s.lookahead = s.strstart - max_start; |
| 6677 | s.strstart = max_start; |
| 6678 | /*** FLUSH_BLOCK(s, 0); ***/ |
| 6679 | flush_block_only(s, false); |
| 6680 | if (s.strm.avail_out === 0) { |
| 6681 | return BS_NEED_MORE; |
| 6682 | } |
| 6683 | /***/ |
| 6684 | |
| 6685 | |
| 6686 | } |
| 6687 | /* Flush if we may have to slide, otherwise block_start may become |
| 6688 | * negative and the data will be gone: |
| 6689 | */ |
| 6690 | if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) { |
nothing calls this directly
no test coverage detected