@internal
(charType?: string)
| 1261 | |
| 1262 | /** @internal */ |
| 1263 | trimEndAborted(charType?: string): boolean { |
| 1264 | const rx = new RegExp(`${charType || '\\s'}+$`) |
| 1265 | |
| 1266 | this.outro = this.outro.replace(rx, '') |
| 1267 | if (this.outro.length) |
| 1268 | return true |
| 1269 | |
| 1270 | let chunk: Chunk | null = this.lastChunk |
| 1271 | |
| 1272 | do { |
| 1273 | const end = chunk.end |
| 1274 | const aborted = chunk.trimEnd(rx) |
| 1275 | |
| 1276 | // if chunk was trimmed, we have a new lastChunk |
| 1277 | if (chunk.end !== end) { |
| 1278 | const next = chunk.next! // chunk.trimEnd() just split this chunk, so a successor exists |
| 1279 | if (this.lastChunk === chunk) { |
| 1280 | this.lastChunk = next |
| 1281 | } |
| 1282 | |
| 1283 | this.byEnd.set(chunk.end, chunk) |
| 1284 | this.byStart.set(next.start, next) |
| 1285 | this.byEnd.set(next.end, next) |
| 1286 | } |
| 1287 | |
| 1288 | if (aborted) |
| 1289 | return true |
| 1290 | chunk = chunk.previous |
| 1291 | } while (chunk) |
| 1292 | |
| 1293 | // like Chunk#trimEnd, carry on into the intro once everything after it has |
| 1294 | // been trimmed away, since the intro is then the end of the string |
| 1295 | this.intro = this.intro.replace(rx, '') |
| 1296 | return this.intro.length > 0 |
| 1297 | } |
| 1298 | |
| 1299 | /** |
| 1300 | * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end. |