min-indent ![Build Status](https://camo.githubusercontent.com/cc5548d7b84502feb07d78ef867bfdb2fa120908d3fe0867917cf1bf4be67b2c/68747470733a2f2f7472617669732d63692e6f72672f7468656a616d65736b796c652f6d696e2d696e64656e742e7376673f6272616e63683d6d6173746572)
Get the shortest leading whitespace from lines in a string
The line with the least number of leading whitespace, ignoring empty lines, determines the number.
Useful for removing redundant indentation.
Install
$ npm install --save min-indent
Usage
const minIndent = require('min-indent');
const str = '\tunicorn\n\t\tcake';
/*
unicorn
cake
*/
minIndent(str); // 1
Related
- strip-indent - Strip leading whitespace from each line in a string
- strip-indent-cli - CLI for this module
- indent-string - Indent each line in a string
License
MIT © James Kyle