终点
根据给定的文本和操作系统确定 EOL .
安装
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);
APIs 密码
function endOfLine(): string
确定OS特定线尾标记. 等值为 o. 伊欧。 。 。 .
function endOfLine(text: string): string
确定给定文本的行尾标记。 以下标记将被识别:
\n\r\n\r\n\r
如果找不到EOL的话, o. 伊欧 将返回.
function endOfLineForFile(filePath: string): string
确定给定文件的行尾标记 .
如果文件不存在或无法读取, o. 伊欧 将返回.
许可证
麻省理工学院