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

Method overwrite

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

546 * It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
547 */
548 overwrite(
549 start: number,
550 end: number,
551 content: string,
552 options?: boolean | OverwriteOptions,
553 ): this {
554 const optionObject = typeof options === 'object' && options ? options : {}
555 return this.update(start, end, content, {
556 ...optionObject,
557 overwrite: !optionObject.contentOnly,
558 })
559 }
560
561 /**
562 * Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.

Callers 3

_replaceRegexpMethod · 0.95
_replaceStringMethod · 0.95
_replaceAllStringMethod · 0.95

Calls 1

updateMethod · 0.95

Tested by

no test coverage detected