MCPcopy Create free account
hub / github.com/EmNudge/watlings / parsePatch

Function parsePatch

scripts/utils/patch.mjs:31–40  ·  view source on GitHub ↗
(patchString)

Source from the content-addressed store, hash-verified

29
30/** @param {string} patchString */
31export function parsePatch(patchString) {
32 return [...patchString.matchAll(PATCH_REGEX)].map(({ groups }) => {
33 const { srcRange, addLines, delLines } = groups;
34
35 const [start, end] = srcRange.split(',').map(Number);
36 const length = end ? end - (start - 1) : 1;
37 const lines = addLines?.trim().split('\n').map(line => line.slice(2)) ?? [];
38 return { start, deleteCount: length, addLines: lines, delLines };
39 })
40}
41
42/**
43 * @param {string} patchString

Callers 2

show-solution.mjsFile · 0.90
patchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected