MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / trimEndAborted

Method trimEndAborted

src/MagicString.ts:1029–1059  ·  view source on GitHub ↗

@internal

(charType?: string)

Source from the content-addressed store, hash-verified

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.

Callers 2

trimEndMethod · 0.95
trimEndMethod · 0.45

Calls 2

replaceMethod · 0.45
trimEndMethod · 0.45

Tested by

no test coverage detected