@internal
(charType?: string)
| 1289 | |
| 1290 | /** @internal */ |
| 1291 | trimEndAborted(charType?: string): boolean { |
| 1292 | const rx = new RegExp(`${charType || '\\s'}+$`) |
| 1293 | |
| 1294 | this.outro = this.outro.replace(rx, '') |
| 1295 | if (this.outro.length) |
| 1296 | return true |
| 1297 | |
| 1298 | let chunk = this.lastChunk |
| 1299 | |
| 1300 | do { |
| 1301 | const end = chunk.end |
| 1302 | const aborted = chunk.trimEnd(rx) |
| 1303 | |
| 1304 | // if chunk was trimmed, we have a new lastChunk |
| 1305 | if (chunk.end !== end) { |
| 1306 | if (this.lastChunk === chunk) { |
| 1307 | this.lastChunk = chunk.next |
| 1308 | } |
| 1309 | |
| 1310 | this.byEnd.set(chunk.end, chunk) |
| 1311 | this.byStart.set(chunk.next.start, chunk.next) |
| 1312 | this.byEnd.set(chunk.next.end, chunk.next) |
| 1313 | } |
| 1314 | |
| 1315 | if (aborted) |
| 1316 | return true |
| 1317 | chunk = chunk.previous |
| 1318 | } while (chunk) |
| 1319 | |
| 1320 | // like Chunk#trimEnd, carry on into the intro once everything after it has |
| 1321 | // been trimmed away, since the intro is then the end of the string |
| 1322 | this.intro = this.intro.replace(rx, '') |
| 1323 | return this.intro.length > 0 |
| 1324 | } |
| 1325 | |
| 1326 | /** |
| 1327 | * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end. |