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

Method trimStartAborted

src/MagicString.ts:1070–1099  ·  view source on GitHub ↗

@internal

(charType?: string)

Source from the content-addressed store, hash-verified

1068
1069 /** @internal */
1070 trimStartAborted(charType?: string): boolean {
1071 const rx = new RegExp(`^${charType || '\\s'}+`)
1072
1073 this.intro = this.intro.replace(rx, '')
1074 if (this.intro.length)
1075 return true
1076
1077 let chunk = this.firstChunk
1078
1079 do {
1080 const end = chunk.end
1081 const aborted = chunk.trimStart(rx)
1082
1083 if (chunk.end !== end) {
1084 // special case...
1085 if (chunk === this.lastChunk)
1086 this.lastChunk = chunk.next
1087
1088 this.byEnd[chunk.end] = chunk
1089 this.byStart[chunk.next.start] = chunk.next
1090 this.byEnd[chunk.next.end] = chunk.next
1091 }
1092
1093 if (aborted)
1094 return true
1095 chunk = chunk.next
1096 } while (chunk)
1097
1098 return false
1099 }
1100
1101 /**
1102 * 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