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

Method trimStartAborted

src/MagicString.ts:1118–1147  ·  view source on GitHub ↗

@internal

(charType?: string)

Source from the content-addressed store, hash-verified

1116
1117 /** @internal */
1118 trimStartAborted(charType?: string): boolean {
1119 const rx = new RegExp(`^${charType || '\\s'}+`)
1120
1121 this.intro = this.intro.replace(rx, '')
1122 if (this.intro.length)
1123 return true
1124
1125 let chunk = this.firstChunk
1126
1127 do {
1128 const end = chunk.end
1129 const aborted = chunk.trimStart(rx)
1130
1131 if (chunk.end !== end) {
1132 // special case...
1133 if (chunk === this.lastChunk)
1134 this.lastChunk = chunk.next
1135
1136 this.byEnd.set(chunk.end, chunk)
1137 this.byStart.set(chunk.next.start, chunk.next)
1138 this.byEnd.set(chunk.next.end, chunk.next)
1139 }
1140
1141 if (aborted)
1142 return true
1143 chunk = chunk.next
1144 } while (chunk)
1145
1146 return false
1147 }
1148
1149 /**
1150 * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.

Callers 2

trimStartMethod · 0.95
trimStartMethod · 0.45

Calls 2

replaceMethod · 0.45
trimStartMethod · 0.45

Tested by

no test coverage detected