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

Method appendRight

src/MagicString.ts:166–190  ·  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

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

Callers 3

replaceMatchMethod · 0.95
_replaceStringMethod · 0.95
_replaceAllStringMethod · 0.95

Calls 3

_splitMethod · 0.95
timeMethod · 0.80
timeEndMethod · 0.80

Tested by

no test coverage detected