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

Method overwrite

src/MagicString.ts:757–768  ·  view source on GitHub ↗

* Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in * that range. The same restrictions as `s.remove()` apply. * * The fourth argument is optional. It can have a storeName property - if true, the original name will be stored * for

(
    start: number,
    end: number,
    content: string,
    options?: boolean | OverwriteOptions,
  )

Source from the content-addressed store, hash-verified

755 * It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
756 */
757 overwrite(
758 start: number,
759 end: number,
760 content: string,
761 options?: boolean | OverwriteOptions,
762 ): this {
763 const optionObject = typeof options === 'object' && options ? options : {}
764 return this.update(start, end, content, {
765 ...optionObject,
766 overwrite: !optionObject.contentOnly,
767 })
768 }
769
770 /**
771 * Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.

Callers 3

replaceMatchMethod · 0.95
_replaceStringMethod · 0.95
_replaceAllStringMethod · 0.95

Calls 1

updateMethod · 0.95

Tested by

no test coverage detected