aboutsummaryrefslogtreecommitdiff
path: root/node_modules/detect-newline
diff options
context:
space:
mode:
authorJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
committerJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
commit080c5819d87b933816d724a83f3bf4f1686770a7 (patch)
tree4a2ccc68b27edf7d4cbc586c932cc7542b655e19 /node_modules/detect-newline
parent5ac7049a9d30733165cc212dee308163c2a14644 (diff)
parentd003b82235a9329f912522a2f70aa950dfce4998 (diff)
downloadLYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.tar.gz
LYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.zip
Merge branch 'master' of https://github.com/JoelHMikael/FoodJS
Updating remote changes
Diffstat (limited to 'node_modules/detect-newline')
-rw-r--r--node_modules/detect-newline/index.d.ts26
-rw-r--r--node_modules/detect-newline/index.js21
-rw-r--r--node_modules/detect-newline/license9
-rw-r--r--node_modules/detect-newline/package.json39
-rw-r--r--node_modules/detect-newline/readme.md42
5 files changed, 137 insertions, 0 deletions
diff --git a/node_modules/detect-newline/index.d.ts b/node_modules/detect-newline/index.d.ts
new file mode 100644
index 0000000..1f32fd2
--- /dev/null
+++ b/node_modules/detect-newline/index.d.ts
@@ -0,0 +1,26 @@
+declare const detectNewline: {
+ /**
+ Detect the dominant newline character of a string.
+
+ @returns The detected newline or `undefined` when no newline character is found.
+
+ @example
+ ```
+ import detectNewline = require('detect-newline');
+
+ detectNewline('foo\nbar\nbaz\r\n');
+ //=> '\n'
+ ```
+ */
+ (string: string): '\r\n' | '\n' | undefined;
+
+ /**
+ Detect the dominant newline character of a string.
+
+ @returns The detected newline or `\n` when no newline character is found or the input is not a string.
+ */
+ graceful(string: string): '\r\n' | '\n';
+ graceful(string?: unknown): '\n';
+};
+
+export = detectNewline;
diff --git a/node_modules/detect-newline/index.js b/node_modules/detect-newline/index.js
new file mode 100644
index 0000000..987ed87
--- /dev/null
+++ b/node_modules/detect-newline/index.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const detectNewline = string => {
+ if (typeof string !== 'string') {
+ throw new TypeError('Expected a string');
+ }
+
+ const newlines = string.match(/(?:\r?\n)/g) || [];
+
+ if (newlines.length === 0) {
+ return;
+ }
+
+ const crlf = newlines.filter(newline => newline === '\r\n').length;
+ const lf = newlines.length - crlf;
+
+ return crlf > lf ? '\r\n' : '\n';
+};
+
+module.exports = detectNewline;
+module.exports.graceful = string => (typeof string === 'string' && detectNewline(string)) || '\n';
diff --git a/node_modules/detect-newline/license b/node_modules/detect-newline/license
new file mode 100644
index 0000000..e7af2f7
--- /dev/null
+++ b/node_modules/detect-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/detect-newline/package.json b/node_modules/detect-newline/package.json
new file mode 100644
index 0000000..1adf246
--- /dev/null
+++ b/node_modules/detect-newline/package.json
@@ -0,0 +1,39 @@
+{
+ "name": "detect-newline",
+ "version": "3.1.0",
+ "description": "Detect the dominant newline character of a string",
+ "license": "MIT",
+ "repository": "sindresorhus/detect-newline",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "scripts": {
+ "test": "xo && ava && tsd"
+ },
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "keywords": [
+ "newline",
+ "linebreak",
+ "line-break",
+ "line",
+ "lf",
+ "crlf",
+ "eol",
+ "linefeed",
+ "character",
+ "char"
+ ],
+ "devDependencies": {
+ "ava": "^1.4.1",
+ "tsd": "^0.7.2",
+ "xo": "^0.24.0"
+ }
+}
diff --git a/node_modules/detect-newline/readme.md b/node_modules/detect-newline/readme.md
new file mode 100644
index 0000000..eee16c2
--- /dev/null
+++ b/node_modules/detect-newline/readme.md
@@ -0,0 +1,42 @@
+# detect-newline [![Build Status](https://travis-ci.org/sindresorhus/detect-newline.svg?branch=master)](https://travis-ci.org/sindresorhus/detect-newline)
+
+> Detect the dominant newline character of a string
+
+
+## Install
+
+```
+$ npm install detect-newline
+```
+
+
+## Usage
+
+```js
+const detectNewline = require('detect-newline');
+
+detectNewline('foo\nbar\nbaz\r\n');
+//=> '\n'
+```
+
+
+## API
+
+### detectNewline(string)
+
+Returns the detected newline or `undefined` when no newline character is found.
+
+### detectNewline.graceful(unknown)
+
+Returns the detected newline or `\n` when no newline character is found or the input is not a string.
+
+
+## Related
+
+- [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
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)