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

Method prependRight

src/MagicString.ts:691–714  ·  view source on GitHub ↗

* Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`

(index: number, content: string)

Source from the content-addressed store, hash-verified

689 * Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
690 */
691 prependRight(index: number, content: string): this {
692 index = index + this.offset
693
694 if (typeof content !== 'string')
695 throw new TypeError('inserted content must be a string')
696
697 if (DEBUG)
698 this.stats.time('insertRight')
699
700 this._split(index)
701
702 const chunk = this.byStart[index]
703
704 if (chunk) {
705 chunk.prependRight(content)
706 }
707 else {
708 this.outro = content + this.outro
709 }
710
711 if (DEBUG)
712 this.stats.timeEnd('insertRight')
713 return this
714 }
715
716 /**
717 * Removes the characters from `start` to `end` (of the original string, **not** the generated string).

Callers 2

insertRightMethod · 0.95
indentAtMethod · 0.45

Calls 3

_splitMethod · 0.95
timeMethod · 0.80
timeEndMethod · 0.80

Tested by

no test coverage detected