Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detect-newline

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-newline - npm Package Compare versions

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 @@

22

package.json
{
"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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc