• Home
Name Date Size #Lines LOC

..--

index.jsD12-May-2024465 2518

licenseD12-May-20241.1 KiB2217

package.jsonD12-May-20241.5 KiB7372

readme.mdD12-May-2024867 4322

readme.md

1# detect-newline [![Build Status](https://travis-ci.org/sindresorhus/detect-newline.svg?branch=master)](https://travis-ci.org/sindresorhus/detect-newline)
2
3> Detect the dominant newline character of a string
4
5
6## Install
7
8```
9$ npm install --save detect-newline
10```
11
12
13## Usage
14
15```js
16const detectNewline = require('detect-newline');
17
18detectNewline('foo\nbar\nbaz\r\n');
19//=> '\n'
20```
21
22
23## API
24
25### detectNewline(input)
26
27Returns detected newline or `null` when no newline character is found.
28
29### detectNewline.graceful(input)
30
31Returns detected newline or `\n` when no newline character is found.
32
33
34## Related
35
36- [detect-newline-cli](https://github.com/sindresorhus/detect-newline-cli) - CLI for this module
37- [detect-indent](https://github.com/sindresorhus/detect-indent) - Detect the indentation of code
38
39
40## License
41
42MIT © [Sindre Sorhus](http://sindresorhus.com)
43