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

Function splitLines

src/patch/create.ts:633–644  ·  view source on GitHub ↗

* Split `text` into an array of lines, including the trailing newline character (where present)

(text: string)

Source from the content-addressed store, hash-verified

631 * Split `text` into an array of lines, including the trailing newline character (where present)
632 */
633function splitLines(text: string): string[] {
634 const hasTrailingNl = text.endsWith('\n');
635 const result = text.split('\n').map(line => line + '\n');
636 if (hasTrailingNl) {
637 result.pop();
638 } else {
639 result.push(
640 (result.pop() as string).slice(0, -1)
641 );
642 }
643 return result;
644}

Callers 1

diffLinesResultToPatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected