@zkochan/pnpm
Version:
Fast, disk space efficient package manager
112 lines (111 loc) • 5.31 kB
JSON
{
"_args": [
[
{
"raw": "detect-indent@^5.0.0",
"scope": null,
"escapedName": "detect-indent",
"name": "detect-indent",
"rawSpec": "^5.0.0",
"spec": ">=5.0.0 <6.0.0",
"type": "range"
},
"/home/zkochan/src/pnpm/packages/pnpm/node_modules/write-json-file"
]
],
"_from": "detect-indent@>=5.0.0 <6.0.0",
"_id": "detect-indent@5.0.0",
"_inCache": true,
"_location": "/detect-indent",
"_nodeVersion": "4.6.0",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/detect-indent-5.0.0.tgz_1476992892715_0.3219247553497553"
},
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"_npmVersion": "2.15.9",
"_phantomChildren": {},
"_requested": {
"raw": "detect-indent@^5.0.0",
"scope": null,
"escapedName": "detect-indent",
"name": "detect-indent",
"rawSpec": "^5.0.0",
"spec": ">=5.0.0 <6.0.0",
"type": "range"
},
"_requiredBy": [
"/write-json-file",
"/write-pkg/write-json-file"
],
"_resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz",
"_shasum": "3871cc0a6a002e8c3e5b3cf7f336264675f06b9d",
"_shrinkwrap": null,
"_spec": "detect-indent@^5.0.0",
"_where": "/home/zkochan/src/pnpm/packages/pnpm/node_modules/write-json-file",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/detect-indent/issues"
},
"dependencies": {},
"description": "Detect the indentation of code",
"devDependencies": {
"ava": "*",
"xo": "*"
},
"directories": {},
"dist": {
"shasum": "3871cc0a6a002e8c3e5b3cf7f336264675f06b9d",
"tarball": "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"gitHead": "6c7485c2e5b74abc11a8870b550a9d385beac9e0",
"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 [](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\nconst fs = require('fs');\nconst detectIndent = require('detect-indent');\n\n/*\n{\n \"ilove\": \"pizza\"\n}\n*/\nconst file = fs.readFileSync('foo.json', 'utf8');\n\n// tries to detect the indentation and falls back to a default if it can't\nconst indent = detectIndent(file).indent || ' ';\n\nconst 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, for example `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- [detect-newline](https://github.com/sindresorhus/detect-newline) - Detect the dominant newline character of a string\n\n\n## License\n\nMIT © [Sindre Sorhus](https://sindresorhus.com)\n",
"readmeFilename": "readme.md",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/detect-indent.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "5.0.0",
"xo": {
"esnext": true
}
}