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

Method appendRight

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

158 * See also `s.prependRight(...)`.
159 */
160 appendRight(index: number, content: string): this {
161 index = index + this.offset
162
163 if (typeof content !== 'string')
164 throw new TypeError('inserted content must be a string')
165
166 if (DEBUG)
167 this.stats.time('appendRight')
168
169 this._split(index)
170
171 const chunk = this.byStart.get(index)
172
173 if (chunk) {
174 chunk.appendRight(content)
175 }
176 else {
177 this.outro += content
178 }
179
180 if (DEBUG)
181 this.stats.timeEnd('appendRight')
182 return this
183 }
184
185 /**
186 * 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