MCPcopy Create free account
hub / github.com/kpdecker/jsdiff / swapPrefix

Function swapPrefix

src/patch/reverse.ts:3–14  ·  view source on GitHub ↗
(fileName: string | undefined)

Source from the content-addressed store, hash-verified

1import type { StructuredPatch } from '../types.js';
2
3function swapPrefix(fileName: string | undefined): string | undefined {
4 if (fileName === undefined || fileName === '/dev/null') {
5 return fileName;
6 }
7 if (fileName.startsWith('a/')) {
8 return 'b/' + fileName.slice(2);
9 }
10 if (fileName.startsWith('b/')) {
11 return 'a/' + fileName.slice(2);
12 }
13 return fileName;
14}
15
16/**
17 * Returns a new structured patch which when applied will undo the original `patch`.

Callers 1

reversePatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected