aboutsummaryrefslogtreecommitdiff
path: root/node_modules/strip-final-newline
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/strip-final-newline')
-rw-r--r--node_modules/strip-final-newline/index.js16
-rw-r--r--node_modules/strip-final-newline/license9
-rw-r--r--node_modules/strip-final-newline/package.json40
-rw-r--r--node_modules/strip-final-newline/readme.md30
4 files changed, 95 insertions, 0 deletions
diff --git a/node_modules/strip-final-newline/index.js b/node_modules/strip-final-newline/index.js
new file mode 100644
index 0000000..78fc0c5
--- /dev/null
+++ b/node_modules/strip-final-newline/index.js
@@ -0,0 +1,16 @@
+'use strict';
+
+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 (input[input.length - 1] === CR) {
+ input = input.slice(0, input.length - 1);
+ }
+
+ return input;
+};
diff --git a/node_modules/strip-final-newline/license b/node_modules/strip-final-newline/license
new file mode 100644
index 0000000..e7af2f7
--- /dev/null
+++ b/node_modules/strip-final-newline/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/strip-final-newline/package.json b/node_modules/strip-final-newline/package.json
new file mode 100644
index 0000000..d9f2a6c
--- /dev/null
+++ b/node_modules/strip-final-newline/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "strip-final-newline",
+ "version": "2.0.0",
+ "description": "Strip the final newline character from a string/buffer",
+ "license": "MIT",
+ "repository": "sindresorhus/strip-final-newline",
+ "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"
+ }
+}
diff --git a/node_modules/strip-final-newline/readme.md b/node_modules/strip-final-newline/readme.md
new file mode 100644
index 0000000..32dfd50
--- /dev/null
+++ b/node_modules/strip-final-newline/readme.md
@@ -0,0 +1,30 @@
+# 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 the final [newline character](https://en.wikipedia.org/wiki/Newline) from a string/buffer
+
+Can be useful when parsing the output of, for example, `ChildProcess#execFile`, as [binaries usually output a newline at the end](https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline). Normally, you would use `stdout.trim()`, but that would also remove newlines at the start and whitespace.
+
+
+## Install
+
+```
+$ npm install strip-final-newline
+```
+
+
+## Usage
+
+```js
+const stripFinalNewline = require('strip-final-newline');
+
+stripFinalNewline('foo\nbar\n\n');
+//=> 'foo\nbar\n'
+
+stripFinalNewline(Buffer.from('foo\nbar\n\n')).toString();
+//=> 'foo\nbar\n'
+```
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)