detect-newline

Detect the dominant newline character of a string

MIT 13 个版本
安装
npm install detect-newline
yarn add detect-newline
pnpm add detect-newline
bun add detect-newline
README

detect-newline

Detect the dominant newline character of a string

Install

npm install detect-newline

Usage

import {detectNewline} from 'detect-newline';

detectNewline('foo\nbar\nbaz\r\n');
//=> '\n'

API

detectNewline(string)

Returns the detected newline or undefined when no newline character is found or \n when no dominant newline is present.

detectNewlineGraceful(unknown)

Returns the detected newline or \n when no newline character is found, no dominant newline is present, or the input is not a string.

版本列表
4.0.1 2023-09-22
4.0.0 2021-10-14
3.1.0 2019-11-13
3.0.0 2019-04-11
2.1.0 2016-02-16
2.0.1 2016-02-09
2.0.0 2016-02-09
1.0.3 2015-02-16
1.0.2 2015-01-24
1.0.1 2014-08-17
1.0.0 2014-08-14
0.1.1 2014-06-28
0.1.0 2014-06-28