| 744 | } |
| 745 | |
| 746 | trimEndAborted(charType) { |
| 747 | const rx = new RegExp((charType || '\\s') + '+$'); |
| 748 | |
| 749 | this.outro = this.outro.replace(rx, ''); |
| 750 | if (this.outro.length) return true; |
| 751 | |
| 752 | let chunk = this.lastChunk; |
| 753 | |
| 754 | do { |
| 755 | const end = chunk.end; |
| 756 | const aborted = chunk.trimEnd(rx); |
| 757 | |
| 758 | // if chunk was trimmed, we have a new lastChunk |
| 759 | if (chunk.end !== end) { |
| 760 | if (this.lastChunk === chunk) { |
| 761 | this.lastChunk = chunk.next; |
| 762 | } |
| 763 | |
| 764 | this.byEnd[chunk.end] = chunk; |
| 765 | this.byStart[chunk.next.start] = chunk.next; |
| 766 | this.byEnd[chunk.next.end] = chunk.next; |
| 767 | } |
| 768 | |
| 769 | if (aborted) return true; |
| 770 | chunk = chunk.previous; |
| 771 | } while (chunk); |
| 772 | |
| 773 | return false; |
| 774 | } |
| 775 | |
| 776 | trimEnd(charType) { |
| 777 | this.trimEndAborted(charType); |