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

Method prependRight

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

690 * Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
691 */
692 prependRight(index: number, content: string): this {
693 index = index + this.offset
694
695 if (typeof content !== 'string')
696 throw new TypeError('inserted content must be a string')
697
698 if (DEBUG)
699 this.stats.time('insertRight')
700
701 this._split(index)
702
703 const chunk = this.byStart.get(index)
704
705 if (chunk) {
706 chunk.prependRight(content)
707 }
708 else {
709 this.outro = content + this.outro
710 }
711
712 if (DEBUG)
713 this.stats.timeEnd('insertRight')
714 return this
715 }
716
717 /**
718 * 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