aboutsummaryrefslogtreecommitdiff
path: root/node_modules/detect-indent
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-03 01:33:53 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-03 01:33:53 +0100
commitd1291f67551c58168af43698a359cb5ddfd266b0 (patch)
tree55a13ed29fe1915e3f42f1b1b7038dafa2e975a7 /node_modules/detect-indent
parentd0a0695fb5d34996850723f7d4b1b59c3df909c2 (diff)
downloadwallet-core-d1291f67551c58168af43698a359cb5ddfd266b0.tar.xz
node_modules
Diffstat (limited to 'node_modules/detect-indent')
-rwxr-xr-xnode_modules/detect-indent/cli.js55
-rw-r--r--node_modules/detect-indent/index.js5
l---------node_modules/detect-indent/node_modules/.bin/repeating1
-rwxr-xr-xnode_modules/detect-indent/node_modules/repeating/cli.js36
-rw-r--r--node_modules/detect-indent/node_modules/repeating/index.js24
-rw-r--r--node_modules/detect-indent/node_modules/repeating/license21
-rw-r--r--node_modules/detect-indent/node_modules/repeating/package.json105
-rw-r--r--node_modules/detect-indent/node_modules/repeating/readme.md40
-rw-r--r--node_modules/detect-indent/package.json107
-rw-r--r--node_modules/detect-indent/readme.md44
10 files changed, 40 insertions, 398 deletions
diff --git a/node_modules/detect-indent/cli.js b/node_modules/detect-indent/cli.js
deleted file mode 100755
index 0fb804e1a..000000000
--- a/node_modules/detect-indent/cli.js
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env node
-'use strict';
-var fs = require('fs');
-var stdin = require('get-stdin');
-var argv = require('minimist')(process.argv.slice(2));
-var pkg = require('./package.json');
-var detectIndent = require('./');
-var input = argv._[0];
-
-function help() {
- console.log([
- '',
- ' ' + pkg.description,
- '',
- ' Usage',
- ' detect-indent <file>',
- ' echo <string> | detect-indent',
- '',
- ' Example',
- ' echo \' foo\\n bar\' | detect-indent | wc --chars',
- ' 2'
- ].join('\n'));
-}
-
-function init(data) {
- var indent = detectIndent(data).indent;
-
- if (indent !== null) {
- process.stdout.write(indent);
- } else {
- console.error('Indentation could not be detected');
- process.exit(2);
- }
-}
-
-if (argv.help) {
- help();
- return;
-}
-
-if (argv.version) {
- console.log(pkg.version);
- return;
-}
-
-if (process.stdin.isTTY) {
- if (!input) {
- help();
- return;
- }
-
- init(fs.readFileSync(input, 'utf8'));
-} else {
- stdin(init);
-}
diff --git a/node_modules/detect-indent/index.js b/node_modules/detect-indent/index.js
index e9b91424c..c2da33799 100644
--- a/node_modules/detect-indent/index.js
+++ b/node_modules/detect-indent/index.js
@@ -1,3 +1,4 @@
+/* eslint-disable guard-for-in */
'use strict';
var repeating = require('repeating');
@@ -18,7 +19,7 @@ function getMostUsed(indents) {
if (u > maxUsed || u === maxUsed && w > maxWeight) {
maxUsed = u;
maxWeight = w;
- result = +n;
+ result = Number(n);
}
}
@@ -92,7 +93,7 @@ module.exports = function (str) {
}
} else if (current) {
// if the last action was an indent, increment the weight
- current[1] += +isIndent;
+ current[1] += Number(isIndent);
}
});
diff --git a/node_modules/detect-indent/node_modules/.bin/repeating b/node_modules/detect-indent/node_modules/.bin/repeating
deleted file mode 120000
index cdedec32e..000000000
--- a/node_modules/detect-indent/node_modules/.bin/repeating
+++ /dev/null
@@ -1 +0,0 @@
-../repeating/cli.js \ No newline at end of file
diff --git a/node_modules/detect-indent/node_modules/repeating/cli.js b/node_modules/detect-indent/node_modules/repeating/cli.js
deleted file mode 100755
index 9bb87d4a7..000000000
--- a/node_modules/detect-indent/node_modules/repeating/cli.js
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env node
-'use strict';
-var pkg = require('./package.json');
-var repeating = require('./');
-var argv = process.argv.slice(2);
-
-function help() {
- console.log([
- '',
- ' ' + pkg.description,
- '',
- ' Usage',
- ' $ repeating <string> <count>',
- '',
- ' Example',
- ' $ repeating \'unicorn \' 2',
- ' unicorn unicorn'
- ].join('\n'));
-}
-
-if (process.argv.indexOf('--help') !== -1) {
- help();
- return;
-}
-
-if (process.argv.indexOf('--version') !== -1) {
- console.log(pkg.version);
- return;
-}
-
-if (!argv[1]) {
- console.error('You have to define how many times to repeat the string.');
- process.exit(1);
-}
-
-console.log(repeating(argv[0], Number(argv[1])));
diff --git a/node_modules/detect-indent/node_modules/repeating/index.js b/node_modules/detect-indent/node_modules/repeating/index.js
deleted file mode 100644
index 2d000a8af..000000000
--- a/node_modules/detect-indent/node_modules/repeating/index.js
+++ /dev/null
@@ -1,24 +0,0 @@
-'use strict';
-var isFinite = require('is-finite');
-
-module.exports = function (str, n) {
- if (typeof str !== 'string') {
- throw new TypeError('Expected a string as the first argument');
- }
-
- if (n < 0 || !isFinite(n)) {
- throw new TypeError('Expected a finite positive number');
- }
-
- var ret = '';
-
- do {
- if (n & 1) {
- ret += str;
- }
-
- str += str;
- } while (n = n >> 1);
-
- return ret;
-};
diff --git a/node_modules/detect-indent/node_modules/repeating/license b/node_modules/detect-indent/node_modules/repeating/license
deleted file mode 100644
index 654d0bfe9..000000000
--- a/node_modules/detect-indent/node_modules/repeating/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/node_modules/repeating/package.json b/node_modules/detect-indent/node_modules/repeating/package.json
deleted file mode 100644
index b8fc1695b..000000000
--- a/node_modules/detect-indent/node_modules/repeating/package.json
+++ /dev/null
@@ -1,105 +0,0 @@
-{
- "_args": [
- [
- {
- "raw": "repeating@^1.1.0",
- "scope": null,
- "escapedName": "repeating",
- "name": "repeating",
- "rawSpec": "^1.1.0",
- "spec": ">=1.1.0 <2.0.0",
- "type": "range"
- },
- "/home/dold/repos/taler/wallet-webex/node_modules/detect-indent"
- ]
- ],
- "_from": "repeating@>=1.1.0 <2.0.0",
- "_id": "repeating@1.1.3",
- "_inCache": true,
- "_location": "/detect-indent/repeating",
- "_nodeVersion": "0.12.4",
- "_npmUser": {
- "name": "sindresorhus",
- "email": "sindresorhus@gmail.com"
- },
- "_npmVersion": "2.10.1",
- "_phantomChildren": {},
- "_requested": {
- "raw": "repeating@^1.1.0",
- "scope": null,
- "escapedName": "repeating",
- "name": "repeating",
- "rawSpec": "^1.1.0",
- "spec": ">=1.1.0 <2.0.0",
- "type": "range"
- },
- "_requiredBy": [
- "/detect-indent"
- ],
- "_resolved": "https://registry.npmjs.org/repeating/-/repeating-1.1.3.tgz",
- "_shasum": "3d4114218877537494f97f77f9785fab810fa4ac",
- "_shrinkwrap": null,
- "_spec": "repeating@^1.1.0",
- "_where": "/home/dold/repos/taler/wallet-webex/node_modules/detect-indent",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "bin": {
- "repeating": "cli.js"
- },
- "bugs": {
- "url": "https://github.com/sindresorhus/repeating/issues"
- },
- "dependencies": {
- "is-finite": "^1.0.0"
- },
- "description": "Repeat a string - fast",
- "devDependencies": {
- "ava": "0.0.4"
- },
- "directories": {},
- "dist": {
- "shasum": "3d4114218877537494f97f77f9785fab810fa4ac",
- "tarball": "https://registry.npmjs.org/repeating/-/repeating-1.1.3.tgz"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "files": [
- "index.js",
- "cli.js"
- ],
- "gitHead": "23e93be864952600940d29c8d67f2b9a09d48d81",
- "homepage": "https://github.com/sindresorhus/repeating",
- "keywords": [
- "cli-app",
- "cli",
- "bin",
- "repeat",
- "repeating",
- "string",
- "str",
- "text",
- "fill"
- ],
- "license": "MIT",
- "maintainers": [
- {
- "name": "sindresorhus",
- "email": "sindresorhus@gmail.com"
- }
- ],
- "name": "repeating",
- "optionalDependencies": {},
- "readme": "ERROR: No README data found!",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/sindresorhus/repeating.git"
- },
- "scripts": {
- "test": "node test.js"
- },
- "version": "1.1.3"
-}
diff --git a/node_modules/detect-indent/node_modules/repeating/readme.md b/node_modules/detect-indent/node_modules/repeating/readme.md
deleted file mode 100644
index 4cd86671b..000000000
--- a/node_modules/detect-indent/node_modules/repeating/readme.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# repeating [![Build Status](https://travis-ci.org/sindresorhus/repeating.svg?branch=master)](https://travis-ci.org/sindresorhus/repeating)
-
-> Repeat a string - fast
-
-
-## Usage
-
-```sh
-$ npm install --save repeating
-```
-
-```js
-var repeating = require('repeating');
-
-repeating('unicorn ', 100);
-//=> unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn
-```
-
-
-## CLI
-
-```sh
-$ npm install --global repeating
-```
-
-```
-$ repeating --help
-
- Usage
- repeating <string> <count>
-
- Example
- repeating 'unicorn ' 2
- unicorn unicorn
-```
-
-
-## License
-
-MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/node_modules/detect-indent/package.json b/node_modules/detect-indent/package.json
index d8dfce443..fa477985c 100644
--- a/node_modules/detect-indent/package.json
+++ b/node_modules/detect-indent/package.json
@@ -1,85 +1,24 @@
{
- "_args": [
- [
- {
- "raw": "detect-indent@^3.0.1",
- "scope": null,
- "escapedName": "detect-indent",
- "name": "detect-indent",
- "rawSpec": "^3.0.1",
- "spec": ">=3.0.1 <4.0.0",
- "type": "range"
- },
- "/home/dold/repos/taler/wallet-webex/node_modules/babel-generator"
- ]
- ],
- "_from": "detect-indent@>=3.0.1 <4.0.0",
- "_id": "detect-indent@3.0.1",
- "_inCache": true,
- "_location": "/detect-indent",
- "_nodeVersion": "0.12.0",
- "_npmUser": {
- "name": "sindresorhus",
- "email": "sindresorhus@gmail.com"
- },
- "_npmVersion": "2.5.1",
- "_phantomChildren": {
- "is-finite": "1.0.2"
- },
- "_requested": {
- "raw": "detect-indent@^3.0.1",
- "scope": null,
- "escapedName": "detect-indent",
- "name": "detect-indent",
- "rawSpec": "^3.0.1",
- "spec": ">=3.0.1 <4.0.0",
- "type": "range"
- },
- "_requiredBy": [
- "/babel-generator"
- ],
- "_resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-3.0.1.tgz",
- "_shasum": "9dc5e5ddbceef8325764b9451b02bc6d54084f75",
- "_shrinkwrap": null,
- "_spec": "detect-indent@^3.0.1",
- "_where": "/home/dold/repos/taler/wallet-webex/node_modules/babel-generator",
+ "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": "http://sindresorhus.com"
- },
- "bin": {
- "detect-indent": "cli.js"
- },
- "bugs": {
- "url": "https://github.com/sindresorhus/detect-indent/issues"
- },
- "dependencies": {
- "get-stdin": "^4.0.1",
- "minimist": "^1.1.0",
- "repeating": "^1.1.0"
- },
- "description": "Detect the indentation of code",
- "devDependencies": {
- "mocha": "*"
- },
- "directories": {},
- "dist": {
- "shasum": "9dc5e5ddbceef8325764b9451b02bc6d54084f75",
- "tarball": "https://registry.npmjs.org/detect-indent/-/detect-indent-3.0.1.tgz"
+ "url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
+ "scripts": {
+ "test": "xo && ava"
+ },
"files": [
- "index.js",
- "cli.js"
+ "index.js"
],
- "gitHead": "c046bec94ac5eefeb67ae4501d556c8dcec2914e",
- "homepage": "https://github.com/sindresorhus/detect-indent",
"keywords": [
- "cli",
- "bin",
"indent",
"indentation",
"detect",
@@ -92,22 +31,16 @@
"space",
"tab"
],
- "license": "MIT",
- "maintainers": [
- {
- "name": "sindresorhus",
- "email": "sindresorhus@gmail.com"
- }
- ],
- "name": "detect-indent",
- "optionalDependencies": {},
- "readme": "ERROR: No README data found!",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/sindresorhus/detect-indent.git"
+ "dependencies": {
+ "repeating": "^2.0.0"
},
- "scripts": {
- "test": "mocha"
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
},
- "version": "3.0.1"
+ "xo": {
+ "ignores": [
+ "fixture/**"
+ ]
+ }
}
diff --git a/node_modules/detect-indent/readme.md b/node_modules/detect-indent/readme.md
index c09ffddcd..22938ab88 100644
--- a/node_modules/detect-indent/readme.md
+++ b/node_modules/detect-indent/readme.md
@@ -14,25 +14,29 @@ Pass in a string of any kind of text and get the indentation.
## Install
-```sh
+```
$ npm install --save detect-indent
```
## Usage
+Here we modify a JSON file while persisting the indentation:
+
```js
-// modify a JSON file while persisting the indentation in Node
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';
@@ -50,28 +54,9 @@ fs.writeFileSync('foo.json', JSON.stringify(json, null, indent));
Accepts a string and returns an object with stats about the indentation:
-* `amount`: {Number} the amount of indentation, e.g. `2`
-* `type`: {String|Null} the type of indentation. Possible values are `tab`, `space` or `null` if no indentation is detected
-* `indent`: {String} the actual indentation
-
-
-## CLI
-
-```sh
-$ npm install --global detect-indent
-```
-
-```
-$ detect-indent --help
-
- Usage
- detect-indent <file>
- echo <string> | detect-indent
-
- Example
- echo ' foo\n bar' | detect-indent | wc --chars
- 2
-```
+* `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
@@ -86,7 +71,7 @@ html {
}
body {
- background: grey;
+ background: gray;
}
p {
@@ -96,7 +81,7 @@ p {
}
```
-[Source](https://medium.com/@heatherarthur/detecting-code-indentation-eff3ed0fb56b#3918).
+[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.
@@ -104,7 +89,7 @@ In the following example, the indentation is detected as 4-spaces:
```css
body {
- background: grey;
+ background: gray;
}
p {
@@ -115,6 +100,11 @@ p {
```
+## Related
+
+- [detect-indent-cli](https://github.com/sindresorhus/detect-indent-cli) - CLI for this module
+
+
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)