111 lines
4.9 KiB
JSON
111 lines
4.9 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "detect-indent@^4.0.0",
|
|
"scope": null,
|
|
"escapedName": "detect-indent",
|
|
"name": "detect-indent",
|
|
"rawSpec": "^4.0.0",
|
|
"spec": ">=4.0.0 <5.0.0",
|
|
"type": "range"
|
|
},
|
|
"/home/jdaugherty/work/GT2/GT2-Android/node_modules/babel-generator"
|
|
]
|
|
],
|
|
"_from": "detect-indent@>=4.0.0 <5.0.0",
|
|
"_id": "detect-indent@4.0.0",
|
|
"_inCache": true,
|
|
"_location": "/detect-indent",
|
|
"_nodeVersion": "3.0.0",
|
|
"_npmUser": {
|
|
"name": "sindresorhus",
|
|
"email": "sindresorhus@gmail.com"
|
|
},
|
|
"_npmVersion": "2.13.3",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "detect-indent@^4.0.0",
|
|
"scope": null,
|
|
"escapedName": "detect-indent",
|
|
"name": "detect-indent",
|
|
"rawSpec": "^4.0.0",
|
|
"spec": ">=4.0.0 <5.0.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/babel-generator"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz",
|
|
"_shasum": "f76d064352cdf43a1cb6ce619c4ee3a9475de208",
|
|
"_shrinkwrap": null,
|
|
"_spec": "detect-indent@^4.0.0",
|
|
"_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/babel-generator",
|
|
"author": {
|
|
"name": "Sindre Sorhus",
|
|
"email": "sindresorhus@gmail.com",
|
|
"url": "sindresorhus.com"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/sindresorhus/detect-indent/issues"
|
|
},
|
|
"dependencies": {
|
|
"repeating": "^2.0.0"
|
|
},
|
|
"description": "Detect the indentation of code",
|
|
"devDependencies": {
|
|
"ava": "*",
|
|
"xo": "*"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"shasum": "f76d064352cdf43a1cb6ce619c4ee3a9475de208",
|
|
"tarball": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz"
|
|
},
|
|
"engines": {
|
|
"node": ">=0.10.0"
|
|
},
|
|
"files": [
|
|
"index.js"
|
|
],
|
|
"gitHead": "dbbc78fcb37907116eb120a8324070a1df0e8d86",
|
|
"homepage": "https://github.com/sindresorhus/detect-indent#readme",
|
|
"keywords": [
|
|
"indent",
|
|
"indentation",
|
|
"detect",
|
|
"infer",
|
|
"identify",
|
|
"code",
|
|
"string",
|
|
"text",
|
|
"source",
|
|
"space",
|
|
"tab"
|
|
],
|
|
"license": "MIT",
|
|
"maintainers": [
|
|
{
|
|
"name": "sindresorhus",
|
|
"email": "sindresorhus@gmail.com"
|
|
}
|
|
],
|
|
"name": "detect-indent",
|
|
"optionalDependencies": {},
|
|
"readme": "# detect-indent [![Build Status](https://travis-ci.org/sindresorhus/detect-indent.svg?branch=master)](https://travis-ci.org/sindresorhus/detect-indent)\n\n> Detect the indentation of code\n\nPass in a string of any kind of text and get the indentation.\n\n\n## Use cases\n\n- Persisting the indentation when modifying a file.\n- Have new content match the existing indentation.\n- Setting the right indentation in your editor.\n\n\n## Install\n\n```\n$ npm install --save detect-indent\n```\n\n\n## Usage\n\nHere we modify a JSON file while persisting the indentation:\n\n```js\nvar fs = require('fs');\nvar detectIndent = require('detect-indent');\n\n/*\n{\n \"ilove\": \"pizza\"\n}\n*/\nvar file = fs.readFileSync('foo.json', 'utf8');\n\n// tries to detect the indentation and falls back to a default if it can't\nvar indent = detectIndent(file).indent || ' ';\n\nvar json = JSON.parse(file);\n\njson.ilove = 'unicorns';\n\nfs.writeFileSync('foo.json', JSON.stringify(json, null, indent));\n/*\n{\n \"ilove\": \"unicorns\"\n}\n*/\n```\n\n\n## API\n\nAccepts a string and returns an object with stats about the indentation: \n\n* `amount` {number} - Amount of indentation, e.g. `2` \n* `type` {string|null} - Type of indentation. Possible values are `tab`, `space` or `null` if no indentation is detected \n* `indent` {string} - Actual indentation\n\n\n## Algorithm\n\nThe current algorithm looks for the most common difference between two consecutive non-empty lines.\n\nIn 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:\n\n```css\nhtml {\n box-sizing: border-box;\n}\n\nbody {\n background: gray;\n}\n\np {\n line-height: 1.3em;\n margin-top: 1em;\n text-indent: 2em;\n}\n```\n\n[Source.](https://medium.com/@heatherarthur/detecting-code-indentation-eff3ed0fb56b#3918)\n\nFurthermore, if there are more than one most used difference, the indentation with the most lines is selected.\n\nIn the following example, the indentation is detected as 4-spaces:\n\n```css\nbody {\n background: gray;\n}\n\np {\n line-height: 1.3em;\n margin-top: 1em;\n text-indent: 2em;\n}\n```\n\n\n## Related\n\n- [detect-indent-cli](https://github.com/sindresorhus/detect-indent-cli) - CLI for this module\n\n\n## License\n\nMIT © [Sindre Sorhus](http://sindresorhus.com)\n",
|
|
"readmeFilename": "readme.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/sindresorhus/detect-indent.git"
|
|
},
|
|
"scripts": {
|
|
"test": "xo && ava"
|
|
},
|
|
"version": "4.0.0",
|
|
"xo": {
|
|
"ignores": [
|
|
"fixture/**"
|
|
]
|
|
}
|
|
}
|