detect-indent
- Version 7.0.1
- Published
- 9.75 kB
- No dependencies
- MIT license
Install
npm i detect-indent
yarn add detect-indent
pnpm add detect-indent
Overview
Detect the indentation of code
Index
Functions
Interfaces
Functions
function detectIndent
detectIndent: (string: string) => Indent;
Detect the indentation of code.
Parameter string
A string of any kind of text.
Example 1
import fs from 'node:fs';import detectIndent from 'detect-indent';// {// "ilove": "pizza"// }const file = fs.readFileSync('foo.json', 'utf8');// Tries to detect the indentation and falls back to a default if it can'tconst indent = detectIndent(file).indent || ' ';const json = JSON.parse(file);json.ilove = 'unicorns';fs.writeFileSync('foo.json', JSON.stringify(json, undefined, indent));// {// "ilove": "unicorns"// }
Interfaces
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (4)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/detect-indent
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/detect-indent)
- HTML<a href="https://www.jsdocs.io/package/detect-indent"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 849 ms. - Missing or incorrect documentation? Open an issue for this package.