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

Method appendRight

src/MagicString.ts:163–186  ·  view source on GitHub ↗

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

(index: number, content: string)

Source from the content-addressed store, hash-verified

161 * See also `s.prependRight(...)`.
162 */
163 appendRight(index: number, content: string): this {
164 index = index + this.offset
165
166 if (typeof content !== 'string')
167 throw new TypeError('inserted content must be a string')
168
169 if (DEBUG)
170 this.stats.time('appendRight')
171
172 this._split(index)
173
174 const chunk = this.byStart[index]
175
176 if (chunk) {
177 chunk.appendRight(content)
178 }
179 else {
180 this.outro += content
181 }
182
183 if (DEBUG)
184 this.stats.timeEnd('appendRight')
185 return this
186 }
187
188 /**
189 * Does what you'd expect.

Callers

nothing calls this directly

Calls 3

_splitMethod · 0.95
timeMethod · 0.80
timeEndMethod · 0.80

Tested by

no test coverage detected