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

Method update

tests/fuzz/edit-model.ts:83–101  ·  view source on GitHub ↗
(start: number, end: number, content: string, options?: { overwrite?: boolean })

Source from the content-addressed store, hash-verified

81 }
82
83 update(start: number, end: number, content: string, options?: { overwrite?: boolean }): void {
84 if (start === end)
85 throw new EditModelError('cannot overwrite a zero-length range')
86 this.assertOrdered(start, end)
87 this.split(start)
88 this.split(end)
89 let firstEnd = end
90 for (let i = start + 1; i < end; i++) {
91 if (this.boundaries.has(i)) {
92 firstEnd = i
93 break
94 }
95 }
96 this.empty(start, end)
97 this.text[start] = content
98 this.holderEnd[start] = content === '' ? -1 : firstEnd
99 if (options?.overwrite)
100 this.clearEdgeInserts(start, end)
101 }
102
103 overwrite(start: number, end: number, content: string): void {
104 this.update(start, end, content, { overwrite: true })

Callers 11

overwriteMethod · 0.95
update.test.tsFile · 0.45
slice.test.tsFile · 0.45
replace.test.tsFile · 0.45
createFunction · 0.45
misc.test.tsFile · 0.45
clone.test.tsFile · 0.45
applyOpFunction · 0.45

Calls 5

assertOrderedMethod · 0.95
splitMethod · 0.95
emptyMethod · 0.95
clearEdgeInsertsMethod · 0.95
hasMethod · 0.45

Tested by 2

createFunction · 0.36
applyOpFunction · 0.36