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