MCPcopy
hub / github.com/codeaashu/claude-code / detectLineEndingsForString

Function detectLineEndingsForString

src/utils/fileRead.ts:51–66  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

49}
50
51export function detectLineEndingsForString(content: string): LineEndingType {
52 let crlfCount = 0
53 let lfCount = 0
54
55 for (let i = 0; i < content.length; i++) {
56 if (content[i] === '\n') {
57 if (i > 0 && content[i - 1] === '\r') {
58 crlfCount++
59 } else {
60 lfCount++
61 }
62 }
63 }
64
65 return crlfCount > lfCount ? 'CRLF' : 'LF'
66}
67
68/**
69 * Like readFileSync but also returns the detected encoding and original line

Callers 2

detectLineEndingsFunction · 0.85
readFileSyncWithMetadataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected