mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
react app
This commit is contained in:
55
react-app/node_modules/detect-indent/cli.js
generated
vendored
Executable file
55
react-app/node_modules/detect-indent/cli.js
generated
vendored
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/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);
|
||||
}
|
119
react-app/node_modules/detect-indent/index.js
generated
vendored
Normal file
119
react-app/node_modules/detect-indent/index.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
'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 = +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] += +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
|
||||
};
|
||||
};
|
21
react-app/node_modules/detect-indent/license
generated
vendored
Normal file
21
react-app/node_modules/detect-indent/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
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.
|
103
react-app/node_modules/detect-indent/package.json
generated
vendored
Normal file
103
react-app/node_modules/detect-indent/package.json
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"detect-indent@^3.0.1",
|
||||
"/Users/mromano/dev/react-sfs/node_modules/babel-generator"
|
||||
]
|
||||
],
|
||||
"_from": "detect-indent@>=3.0.1 <4.0.0",
|
||||
"_id": "detect-indent@3.0.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/detect-indent",
|
||||
"_nodeVersion": "0.12.0",
|
||||
"_npmUser": {
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"name": "sindresorhus"
|
||||
},
|
||||
"_npmVersion": "2.5.1",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "detect-indent",
|
||||
"raw": "detect-indent@^3.0.1",
|
||||
"rawSpec": "^3.0.1",
|
||||
"scope": null,
|
||||
"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": "/Users/mromano/dev/react-sfs/node_modules/babel-generator",
|
||||
"author": {
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"name": "Sindre Sorhus",
|
||||
"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": "http://registry.npmjs.org/detect-indent/-/detect-indent-3.0.1.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"cli.js"
|
||||
],
|
||||
"gitHead": "c046bec94ac5eefeb67ae4501d556c8dcec2914e",
|
||||
"homepage": "https://github.com/sindresorhus/detect-indent",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"bin",
|
||||
"indent",
|
||||
"indentation",
|
||||
"detect",
|
||||
"infer",
|
||||
"identify",
|
||||
"code",
|
||||
"string",
|
||||
"text",
|
||||
"source",
|
||||
"space",
|
||||
"tab"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"name": "sindresorhus"
|
||||
}
|
||||
],
|
||||
"name": "detect-indent",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/detect-indent.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "3.0.1"
|
||||
}
|
120
react-app/node_modules/detect-indent/readme.md
generated
vendored
Normal file
120
react-app/node_modules/detect-indent/readme.md
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
# detect-indent [](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
|
||||
|
||||
```sh
|
||||
$ npm install --save detect-indent
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```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';
|
||||
|
||||
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} 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
|
||||
```
|
||||
|
||||
|
||||
## 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: grey;
|
||||
}
|
||||
|
||||
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: grey;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 1.3em;
|
||||
margin-top: 1em;
|
||||
text-indent: 2em;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
Reference in New Issue
Block a user