strip-final-newline
Advanced tools
Comparing version 2.0.0 to 3.0.0
10
index.js
@@ -1,4 +0,2 @@ | ||
'use strict'; | ||
module.exports = input => { | ||
export default function stripFinalNewline(input) { | ||
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt(); | ||
@@ -8,10 +6,10 @@ const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt(); | ||
if (input[input.length - 1] === LF) { | ||
input = input.slice(0, input.length - 1); | ||
input = input.slice(0, -1); | ||
} | ||
if (input[input.length - 1] === CR) { | ||
input = input.slice(0, input.length - 1); | ||
input = input.slice(0, -1); | ||
} | ||
return input; | ||
}; | ||
} |
{ | ||
"name": "strip-final-newline", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Strip the final newline character from a string/buffer", | ||
"license": "MIT", | ||
"repository": "sindresorhus/strip-final-newline", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=12" | ||
}, | ||
@@ -37,5 +40,5 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^0.25.0", | ||
"xo": "^0.23.0" | ||
"ava": "^3.15.0", | ||
"xo": "^0.39.1" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# strip-final-newline [![Build Status](https://travis-ci.com/sindresorhus/strip-final-newline.svg?branch=master)](https://travis-ci.com/sindresorhus/strip-final-newline) | ||
# strip-final-newline | ||
@@ -7,3 +7,2 @@ > Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from a string/buffer | ||
## Install | ||
@@ -15,7 +14,6 @@ | ||
## Usage | ||
```js | ||
const stripFinalNewline = require('strip-final-newline'); | ||
import stripFinalNewline from 'strip-final-newline'; | ||
@@ -29,5 +27,12 @@ stripFinalNewline('foo\nbar\n\n'); | ||
--- | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) | ||
<div align="center"> | ||
<b> | ||
<a href="https://tidelift.com/subscription/pkg/npm-strip-eof?utm_source=npm-strip-eof&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
</b> | ||
<br> | ||
<sub> | ||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
</sub> | ||
</div> |
Sorry, the diff of this file is not supported yet
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
3361
36
Yes
11