MCPcopy Create free account
hub / github.com/arktypeio/arktype / applyEdits

Function applyEdits

ark/repo/bundle.ts:276–283  ·  view source on GitHub ↗
(js: string, edits: Edit[])

Source from the content-addressed store, hash-verified

274type Edit = [start: number, end: number, replacement: string]
275
276const applyEdits = (js: string, edits: Edit[]) =>
277 edits
278 .sort(([l], [r]) => r - l)
279 .reduce(
280 (result, [start, end, replacement]) =>
281 result.slice(0, start) + replacement + result.slice(end),
282 js
283 )
284
285const parse = (js: string) =>
286 ts.createSourceFile(

Callers 4

stripBareImportsFunction · 0.70
reexportImportsFunction · 0.70
parsedLazilyFunction · 0.70

Calls 2

reduceMethod · 0.80
sortMethod · 0.80

Tested by

no test coverage detected