UNPKG

1.41 kBMarkdownView Raw
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
14import indentString from 'indent-string';
15
16indentString('Unicorns\nRainbows', 4);
17//=> ' Unicorns\n Rainbows'
18
19indentString('Unicorns\nRainbows', 4, {indent: '♥'});
20//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
21```
22
23## API
24
25### indentString(string, count?, options?)
26
27#### string
28
29Type: `string`
30
31The string to indent.
32
33#### count
34
35Type: `number`\
36Default: `1`
37
38How many times you want `options.indent` repeated.
39
40#### options
41
42Type: `object`
43
44##### indent
45
46Type: `string`\
47Default: `' '`
48
49The string to use for the indent.
50
51##### includeEmptyLines
52
53Type: `boolean`\
54Default: `false`
55
56Also 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>