1 | # strip-indent
|
2 |
|
3 | > Strip leading whitespace from each line in a string
|
4 |
|
5 | The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.
|
6 |
|
7 | Useful for removing redundant indentation.
|
8 |
|
9 | ## Install
|
10 |
|
11 | ```
|
12 | $ npm install strip-indent
|
13 | ```
|
14 |
|
15 | ## Usage
|
16 |
|
17 | ```js
|
18 | import stripIndent from 'strip-indent';
|
19 |
|
20 | const string = '\tunicorn\n\t\tcake';
|
21 | /*
|
22 | unicorn
|
23 | cake
|
24 | */
|
25 |
|
26 | stripIndent(string);
|
27 | /*
|
28 | unicorn
|
29 | cake
|
30 | */
|
31 | ```
|
32 |
|
33 | ## Related
|
34 |
|
35 | - [strip-indent-cli](https://github.com/sindresorhus/strip-indent-cli) - CLI for this module
|
36 | - [indent-string](https://github.com/sindresorhus/indent-string) - Indent each line in a string
|
37 |
|
38 | ---
|
39 |
|
40 | <div align="center">
|
41 | <b>
|
42 | <a href="https://tidelift.com/subscription/pkg/npm-strip-indent?utm_source=npm-strip-indent&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
43 | </b>
|
44 | <br>
|
45 | <sub>
|
46 | Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
47 | </sub>
|
48 | </div>
|