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

Function winToUnix

src/patch/line-endings.ts:34–47  ·  view source on GitHub ↗
(patch: StructuredPatch | StructuredPatch[])

Source from the content-addressed store, hash-verified

32export function winToUnix(patches: StructuredPatch[]): StructuredPatch[];
33export function winToUnix(patch: StructuredPatch | StructuredPatch[]): StructuredPatch | StructuredPatch[];
34export function winToUnix(patch: StructuredPatch | StructuredPatch[]): StructuredPatch | StructuredPatch[] {
35 if (Array.isArray(patch)) {
36 // (See comment above equivalent line in unixToWin)
37 return patch.map(p => winToUnix(p));
38 }
39
40 return {
41 ...patch,
42 hunks: patch.hunks.map(hunk => ({
43 ...hunk,
44 lines: hunk.lines.map(line => line.endsWith('\r') ? line.substring(0, line.length - 1) : line)
45 }))
46 };
47}
48
49/**
50 * Returns true if the patch consistently uses Unix line endings (or only involves one line and has

Callers 2

line-endings.jsFile · 0.85
applyStructuredPatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected