diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
commit | cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch) | |
tree | 92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/detect-indent | |
parent | 3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff) | |
download | wallet-core-cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585.tar.xz |
remove node_modules
Diffstat (limited to 'node_modules/detect-indent')
-rw-r--r-- | node_modules/detect-indent/index.js | 120 | ||||
-rw-r--r-- | node_modules/detect-indent/license | 21 | ||||
-rw-r--r-- | node_modules/detect-indent/package.json | 46 | ||||
-rw-r--r-- | node_modules/detect-indent/readme.md | 110 |
4 files changed, 0 insertions, 297 deletions
diff --git a/node_modules/detect-indent/index.js b/node_modules/detect-indent/index.js deleted file mode 100644 index c2da33799..000000000 --- a/node_modules/detect-indent/index.js +++ /dev/null @@ -1,120 +0,0 @@ -/* eslint-disable guard-for-in */ -'use strict'; -var repeating = require('repeating'); - -// detect either spaces or tabs but not both to properly handle tabs -// for indentation and spaces for alignment -var INDENT_RE = /^(?:( )+|\t+)/; - -function getMostUsed(indents) { - var result = 0; - var maxUsed = 0; - var maxWeight = 0; - - for (var n in indents) { - var indent = indents[n]; - var u = indent[0]; - var w = indent[1]; - - if (u > maxUsed || u === maxUsed && w > maxWeight) { - maxUsed = u; - maxWeight = w; - result = Number(n); - } - } - - return result; -} - -module.exports = function (str) { - if (typeof str !== 'string') { - throw new TypeError('Expected a string'); - } - - // used to see if tabs or spaces are the most used - var tabs = 0; - var spaces = 0; - - // remember the size of previous line's indentation - var prev = 0; - - // remember how many indents/unindents as occurred for a given size - // and how much lines follow a given indentation - // - // indents = { - // 3: [1, 0], - // 4: [1, 5], - // 5: [1, 0], - // 12: [1, 0], - // } - var indents = {}; - - // pointer to the array of last used indent - var current; - - // whether the last action was an indent (opposed to an unindent) - var isIndent; - - str.split(/\n/g).forEach(function (line) { - if (!line) { - // ignore empty lines - return; - } - - var indent; - var matches = line.match(INDENT_RE); - - if (!matches) { - indent = 0; - } else { - indent = matches[0].length; - - if (matches[1]) { - spaces++; - } else { - tabs++; - } - } - - var diff = indent - prev; - prev = indent; - - if (diff) { - // an indent or unindent has been detected - - isIndent = diff > 0; - - current = indents[isIndent ? diff : -diff]; - - if (current) { - current[0]++; - } else { - current = indents[diff] = [1, 0]; - } - } else if (current) { - // if the last action was an indent, increment the weight - current[1] += Number(isIndent); - } - }); - - var amount = getMostUsed(indents); - - var type; - var actual; - if (!amount) { - type = null; - actual = ''; - } else if (spaces >= tabs) { - type = 'space'; - actual = repeating(' ', amount); - } else { - type = 'tab'; - actual = repeating('\t', amount); - } - - return { - amount: amount, - type: type, - indent: actual - }; -}; diff --git a/node_modules/detect-indent/license b/node_modules/detect-indent/license deleted file mode 100644 index 654d0bfe9..000000000 --- a/node_modules/detect-indent/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -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-indent/package.json b/node_modules/detect-indent/package.json deleted file mode 100644 index fa477985c..000000000 --- a/node_modules/detect-indent/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "detect-indent", - "version": "4.0.0", - "description": "Detect the indentation of code", - "license": "MIT", - "repository": "sindresorhus/detect-indent", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "indent", - "indentation", - "detect", - "infer", - "identify", - "code", - "string", - "text", - "source", - "space", - "tab" - ], - "dependencies": { - "repeating": "^2.0.0" - }, - "devDependencies": { - "ava": "*", - "xo": "*" - }, - "xo": { - "ignores": [ - "fixture/**" - ] - } -} diff --git a/node_modules/detect-indent/readme.md b/node_modules/detect-indent/readme.md deleted file mode 100644 index 22938ab88..000000000 --- a/node_modules/detect-indent/readme.md +++ /dev/null @@ -1,110 +0,0 @@ -# detect-indent [![Build Status](https://travis-ci.org/sindresorhus/detect-indent.svg?branch=master)](https://travis-ci.org/sindresorhus/detect-indent) - -> Detect the indentation of code - -Pass in a string of any kind of text and get the indentation. - - -## Use cases - -- Persisting the indentation when modifying a file. -- Have new content match the existing indentation. -- Setting the right indentation in your editor. - - -## Install - -``` -$ npm install --save detect-indent -``` - - -## Usage - -Here we modify a JSON file while persisting the indentation: - -```js -var fs = require('fs'); -var detectIndent = require('detect-indent'); - -/* -{ - "ilove": "pizza" -} -*/ -var file = fs.readFileSync('foo.json', 'utf8'); - -// tries to detect the indentation and falls back to a default if it can't -var indent = detectIndent(file).indent || ' '; - -var json = JSON.parse(file); - -json.ilove = 'unicorns'; - -fs.writeFileSync('foo.json', JSON.stringify(json, null, indent)); -/* -{ - "ilove": "unicorns" -} -*/ -``` - - -## API - -Accepts a string and returns an object with stats about the indentation: - -* `amount` {number} - Amount of indentation, e.g. `2` -* `type` {string|null} - Type of indentation. Possible values are `tab`, `space` or `null` if no indentation is detected -* `indent` {string} - Actual indentation - - -## Algorithm - -The current algorithm looks for the most common difference between two consecutive non-empty lines. - -In the following example, even if the 4-space indentation is used 3 times whereas the 2-space one is used 2 times, it is detected as less used because there were only 2 differences with this value instead of 4 for the 2-space indentation: - -```css -html { - box-sizing: border-box; -} - -body { - background: gray; -} - -p { - line-height: 1.3em; - margin-top: 1em; - text-indent: 2em; -} -``` - -[Source.](https://medium.com/@heatherarthur/detecting-code-indentation-eff3ed0fb56b#3918) - -Furthermore, if there are more than one most used difference, the indentation with the most lines is selected. - -In the following example, the indentation is detected as 4-spaces: - -```css -body { - background: gray; -} - -p { - line-height: 1.3em; - margin-top: 1em; - text-indent: 2em; -} -``` - - -## Related - -- [detect-indent-cli](https://github.com/sindresorhus/detect-indent-cli) - CLI for this module - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) |