Determine EOL based on given text and OS.
npm i @dozerg/end-of-line
import { endOfLine } from '@dozerg/end-of-line';
// Detect OS-specific EOL.
const default_eol = endOfLine();
// Detect EOL for a given text.
const text = 'some\ntext\nwith\r\nnewlines\r';
const text_eol = endOfLine(text); // '\n'
// Detect EOL for a file.
const filename = '/path/to/file.ext';
const file_eol = endOfLineForFile(filename);
Determine the OS-specific end-of-line marker. Equivalent to os.EOL.
Determine end-of-line marker for a given text. The following markers will be recognized:
\n
\r\n
\r
\n\r
If there is no EOL found, os.EOL will be returned.
Determine end-of-line marker for a given file.
If file doesn't exist or cannot be read, os.EOL will be returned.
MIT