MCPcopy Create free account
hub / github.com/anomalyco/opencode / convertToLineEnding

Function convertToLineEnding

packages/core/src/tool/edit.ts:44–45  ·  view source on GitHub ↗
(text: string, ending: "\n" | "\r\n")

Source from the content-addressed store, hash-verified

42const normalizeLineEndings = (text: string) => text.replaceAll("\r\n", "\n")
43const detectLineEnding = (text: string): "\n" | "\r\n" => (text.includes("\r\n") ? "\r\n" : "\n")
44const convertToLineEnding = (text: string, ending: "\n" | "\r\n") =>
45 ending === "\n" ? normalizeLineEndings(text) : normalizeLineEndings(text).replaceAll("\n", "\r\n")
46
47const splitBom = (text: string) =>
48 text.startsWith("\uFEFF") ? { bom: true, text: text.slice(1) } : { bom: false, text }

Callers 1

edit.tsFile · 0.70

Calls 1

normalizeLineEndingsFunction · 0.70

Tested by

no test coverage detected