MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / detectLineEndingsForString

Function detectLineEndingsForString

source code/utils/fileRead.ts:53–68  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

51}
52
53export function detectLineEndingsForString(content: string): LineEndingType {
54 let crlfCount = 0
55 let lfCount = 0
56
57 for (let i = 0; i < content.length; i++) {
58 if (content[i] === '\n') {
59 if (i > 0 && content[i - 1] === '\r') {
60 crlfCount++
61 } else {
62 lfCount++
63 }
64 }
65 }
66
67 return crlfCount > lfCount ? 'CRLF' : 'LF'
68}
69
70/**
71 * 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