| 734 | return this.trimStart(charType).trimEnd(charType); |
| 735 | } |
| 736 | trimEndAborted(charType) { |
| 737 | const rx = new RegExp((charType || '\\s') + '+$'); |
| 738 | this.outro = this.outro.replace(rx, ''); |
| 739 | if (this.outro.length) return true; |
| 740 | let chunk = this.lastChunk; |
| 741 | do { |
| 742 | const end = chunk.end; |
| 743 | const aborted = chunk.trimEnd(rx); |
| 744 | if (chunk.end !== end) { |
| 745 | if (this.lastChunk === chunk) { |
| 746 | this.lastChunk = chunk.next; |
| 747 | } |
| 748 | this.byEnd[chunk.end] = chunk; |
| 749 | this.byStart[chunk.next.start] = chunk.next; |
| 750 | this.byEnd[chunk.next.end] = chunk.next; |
| 751 | } |
| 752 | if (aborted) return true; |
| 753 | chunk = chunk.previous; |
| 754 | } while (chunk); |
| 755 | return false; |
| 756 | } |
| 757 | trimEnd(charType) { |
| 758 | this.trimEndAborted(charType); |
| 759 | return this; |