strip-eof
Advanced tools
Comparing version 1.0.0 to 2.0.0
17
index.js
'use strict'; | ||
module.exports = function (x) { | ||
var lf = typeof x === 'string' ? '\n' : '\n'.charCodeAt(); | ||
var cr = typeof x === 'string' ? '\r' : '\r'.charCodeAt(); | ||
if (x[x.length - 1] === lf) { | ||
x = x.slice(0, x.length - 1); | ||
module.exports = input => { | ||
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt(); | ||
const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt(); | ||
if (input[input.length - 1] === LF) { | ||
input = input.slice(0, input.length - 1); | ||
} | ||
if (x[x.length - 1] === cr) { | ||
x = x.slice(0, x.length - 1); | ||
if (input[input.length - 1] === CR) { | ||
input = input.slice(0, input.length - 1); | ||
} | ||
return x; | ||
return input; | ||
}; |
{ | ||
"name": "strip-eof", | ||
"version": "1.0.0", | ||
"description": "Strip the End-Of-File (EOF) character from a string/buffer", | ||
"license": "MIT", | ||
"repository": "sindresorhus/strip-eof", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"strip", | ||
"trim", | ||
"remove", | ||
"delete", | ||
"eof", | ||
"end", | ||
"file", | ||
"newline", | ||
"linebreak", | ||
"character", | ||
"string", | ||
"buffer" | ||
], | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
"name": "strip-eof", | ||
"version": "2.0.0", | ||
"description": "Strip the final newline character from a string/buffer", | ||
"license": "MIT", | ||
"repository": "sindresorhus/strip-eof", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"strip", | ||
"trim", | ||
"remove", | ||
"delete", | ||
"final", | ||
"last", | ||
"end", | ||
"file", | ||
"newline", | ||
"linebreak", | ||
"character", | ||
"string", | ||
"buffer" | ||
], | ||
"devDependencies": { | ||
"ava": "^0.25.0", | ||
"xo": "^0.23.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# strip-eof [![Build Status](https://travis-ci.org/sindresorhus/strip-eof.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-eof) | ||
# strip-eof [![Build Status](https://travis-ci.com/sindresorhus/strip-eof.svg?branch=master)](https://travis-ci.com/sindresorhus/strip-eof) | ||
@@ -9,3 +9,3 @@ > Strip the [End-Of-File](https://en.wikipedia.org/wiki/End-of-file) (EOF) character from a string/buffer | ||
``` | ||
$ npm install --save strip-eof | ||
$ npm install strip-eof | ||
``` | ||
@@ -22,3 +22,3 @@ | ||
stripEof(new Buffer('foo\nbar\n\n')).toString(); | ||
stripEof(Buffer.from('foo\nbar\n\n')).toString(); | ||
//=> 'foo\nbar\n' | ||
@@ -30,2 +30,2 @@ ``` | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
2634
1