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

Method appendRight

src/MagicString.ts:163–187  ·  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 MagicStringError(`content must be a string, got ${typeof content}`)
168 }
169
170 if (DEBUG)
171 this.stats.time('appendRight')
172
173 this._split(index)
174
175 const chunk = this.byStart.get(index)
176
177 if (chunk) {
178 chunk.appendRight(content)
179 }
180 else {
181 this.outro += content
182 }
183
184 if (DEBUG)
185 this.stats.timeEnd('appendRight')
186 return this
187 }
188
189 /**
190 * 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