detect-newline
Advanced tools
Comparing version 1.0.3 to 2.0.0
10
index.js
@@ -8,3 +8,11 @@ 'use strict'; | ||
var newlines = (str.match(/(?:\r?\n)/g) || []); | ||
var crlf = newlines.filter(function (el) { return el === '\r\n'; }).length; | ||
if (newlines.length === 0) { | ||
return null; | ||
} | ||
var crlf = newlines.filter(function (el) { | ||
return el === '\r\n'; | ||
}).length; | ||
var lf = newlines.length - crlf; | ||
@@ -11,0 +19,0 @@ |
{ | ||
"name": "detect-newline", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "Detect the dominant newline character of a string", | ||
@@ -10,7 +10,5 @@ "license": "MIT", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
"url": "sindresorhus.com" | ||
}, | ||
"bin": { | ||
"detect-newline": "cli.js" | ||
}, | ||
"bin": "cli.js", | ||
"engines": { | ||
@@ -20,11 +18,8 @@ "node": ">=0.10.0" | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"cli.js" | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"cli", | ||
"bin", | ||
"newline", | ||
@@ -41,9 +36,6 @@ "linebreak", | ||
], | ||
"dependencies": { | ||
"get-stdin": "^4.0.1", | ||
"minimist": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
@@ -8,3 +8,3 @@ # detect-newline [![Build Status](https://travis-ci.org/sindresorhus/detect-newline.svg?branch=master)](https://travis-ci.org/sindresorhus/detect-newline) | ||
```sh | ||
``` | ||
$ npm install --save detect-newline | ||
@@ -17,30 +17,19 @@ ``` | ||
```js | ||
var detectNewline = require('detect-newline'); | ||
const detectNewline = require('detect-newline'); | ||
detectNewline('foo\nbar\nbaz\r\n'); | ||
//=> \n | ||
//=> '\n' | ||
``` | ||
Returns `null` when no newline character is found. | ||
## CLI | ||
```sh | ||
$ npm install --global detect-newline | ||
``` | ||
## Related | ||
```sh | ||
$ detect-newline --help | ||
- [detect-newline-cli](https://github.com/sindresorhus/detect-newline-cli) - CLI for this module | ||
- [detect-indent](https://github.com/sindresorhus/detect-indent) - Detect the indentation of code | ||
Usage | ||
detect-newline <string> | ||
cat unicorn.txt | detect-newline | ||
Example | ||
detect-newline "$(printf 'Unicorns\nRainbows')" | ||
\n | ||
``` | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
2871
2
4
15
34
- Removedget-stdin@^4.0.1
- Removedminimist@^1.1.0
- Removedget-stdin@4.0.1(transitive)
- Removedminimist@1.2.8(transitive)