(content: string)
| 51 | } |
| 52 | |
| 53 | export 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 |
no outgoing calls
no test coverage detected