1 | # indent-string
|
2 |
|
3 | > Indent each line in a string
|
4 |
|
5 | ## Install
|
6 |
|
7 | ```
|
8 | $ npm install indent-string
|
9 | ```
|
10 |
|
11 | ## Usage
|
12 |
|
13 | ```js
|
14 | import indentString from 'indent-string';
|
15 |
|
16 | indentString('Unicorns\nRainbows', 4);
|
17 | //=> ' Unicorns\n Rainbows'
|
18 |
|
19 | indentString('Unicorns\nRainbows', 4, {indent: '♥'});
|
20 | //=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
|
21 | ```
|
22 |
|
23 | ## API
|
24 |
|
25 | ### indentString(string, count?, options?)
|
26 |
|
27 | #### string
|
28 |
|
29 | Type: `string`
|
30 |
|
31 | The string to indent.
|
32 |
|
33 | #### count
|
34 |
|
35 | Type: `number`\
|
36 | Default: `1`
|
37 |
|
38 | How many times you want `options.indent` repeated.
|
39 |
|
40 | #### options
|
41 |
|
42 | Type: `object`
|
43 |
|
44 | ##### indent
|
45 |
|
46 | Type: `string`\
|
47 | Default: `' '`
|
48 |
|
49 | The string to use for the indent.
|
50 |
|
51 | ##### includeEmptyLines
|
52 |
|
53 | Type: `boolean`\
|
54 | Default: `false`
|
55 |
|
56 | Also indent empty lines.
|
57 |
|
58 | ## Related
|
59 |
|
60 | - [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - CLI for this module
|
61 | - [strip-indent](https://github.com/sindresorhus/strip-indent) - Strip leading whitespace from every line in a string
|
62 |
|
63 | ---
|
64 |
|
65 | <div align="center">
|
66 | <b>
|
67 | <a href="https://tidelift.com/subscription/pkg/npm-indent-string?utm_source=npm-indent-string&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
68 | </b>
|
69 | <br>
|
70 | <sub>
|
71 | Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
72 | </sub>
|
73 | </div>
|