@internal
(charType?: string)
| 1044 | |
| 1045 | /** @internal */ |
| 1046 | trimEndAborted(charType?: string): boolean { |
| 1047 | const rx = new RegExp(`${charType || '\\s'}+$`) |
| 1048 | |
| 1049 | this.outro = this.outro.replace(rx, '') |
| 1050 | if (this.outro.length) |
| 1051 | return true |
| 1052 | |
| 1053 | let chunk = this.lastChunk |
| 1054 | |
| 1055 | do { |
| 1056 | const end = chunk.end |
| 1057 | const aborted = chunk.trimEnd(rx) |
| 1058 | |
| 1059 | // if chunk was trimmed, we have a new lastChunk |
| 1060 | if (chunk.end !== end) { |
| 1061 | if (this.lastChunk === chunk) { |
| 1062 | this.lastChunk = chunk.next |
| 1063 | } |
| 1064 | |
| 1065 | this.byEnd.set(chunk.end, chunk) |
| 1066 | this.byStart.set(chunk.next.start, chunk.next) |
| 1067 | this.byEnd.set(chunk.next.end, chunk.next) |
| 1068 | } |
| 1069 | |
| 1070 | if (aborted) |
| 1071 | return true |
| 1072 | chunk = chunk.previous |
| 1073 | } while (chunk) |
| 1074 | |
| 1075 | return false |
| 1076 | } |
| 1077 | |
| 1078 | /** |
| 1079 | * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end. |