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

Method appendLeft

src/MagicString.ts:133–156  ·  view source on GitHub ↗

* Appends the specified content at the index in the original string. * If a range *ending* with index is subsequently moved, the insert will be moved with it. * See also `s.prependLeft(...)`.

(index: number, content: string)

Source from the content-addressed store, hash-verified

131 * See also `s.prependLeft(...)`.
132 */
133 appendLeft(index: number, content: string): this {
134 index = index + this.offset
135
136 if (typeof content !== 'string')
137 throw new TypeError('inserted content must be a string')
138
139 if (DEBUG)
140 this.stats.time('appendLeft')
141
142 this._split(index)
143
144 const chunk = this.byEnd[index]
145
146 if (chunk) {
147 chunk.appendLeft(content)
148 }
149 else {
150 this.intro += content
151 }
152
153 if (DEBUG)
154 this.stats.timeEnd('appendLeft')
155 return this
156 }
157
158 /**
159 * Appends the specified content at the index in the original string.

Callers 1

insertLeftMethod · 0.95

Calls 3

_splitMethod · 0.95
timeMethod · 0.80
timeEndMethod · 0.80

Tested by

no test coverage detected