@internal
(charType?: string)
| 1027 | |
| 1028 | /** @internal */ |
| 1029 | trimEndAborted(charType?: string): boolean { |
| 1030 | const rx = new RegExp(`${charType || '\\s'}+$`) |
| 1031 | |
| 1032 | this.outro = this.outro.replace(rx, '') |
| 1033 | if (this.outro.length) |
| 1034 | return true |
| 1035 | |
| 1036 | let chunk = this.lastChunk |
| 1037 | |
| 1038 | do { |
| 1039 | const end = chunk.end |
| 1040 | const aborted = chunk.trimEnd(rx) |
| 1041 | |
| 1042 | // if chunk was trimmed, we have a new lastChunk |
| 1043 | if (chunk.end !== end) { |
| 1044 | if (this.lastChunk === chunk) { |
| 1045 | this.lastChunk = chunk.next |
| 1046 | } |
| 1047 | |
| 1048 | this.byEnd[chunk.end] = chunk |
| 1049 | this.byStart[chunk.next.start] = chunk.next |
| 1050 | this.byEnd[chunk.next.end] = chunk.next |
| 1051 | } |
| 1052 | |
| 1053 | if (aborted) |
| 1054 | return true |
| 1055 | chunk = chunk.previous |
| 1056 | } while (chunk) |
| 1057 | |
| 1058 | return false |
| 1059 | } |
| 1060 | |
| 1061 | /** |
| 1062 | * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end. |