Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | # indent-string [![Build Status](https://travis-ci.org/sindresorhus/indent-string.svg?branch=master)](https://travis-ci.org/sindresorhus/indent-string)
|
---|
2 |
|
---|
3 | > Indent each line in a string
|
---|
4 |
|
---|
5 |
|
---|
6 | ## Install
|
---|
7 |
|
---|
8 | ```
|
---|
9 | $ npm install indent-string
|
---|
10 | ```
|
---|
11 |
|
---|
12 |
|
---|
13 | ## Usage
|
---|
14 |
|
---|
15 | ```js
|
---|
16 | const indentString = require('indent-string');
|
---|
17 |
|
---|
18 | indentString('Unicorns\nRainbows', 4);
|
---|
19 | //=> ' Unicorns\n Rainbows'
|
---|
20 |
|
---|
21 | indentString('Unicorns\nRainbows', 4, {indent: '♥'});
|
---|
22 | //=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
|
---|
23 | ```
|
---|
24 |
|
---|
25 |
|
---|
26 | ## API
|
---|
27 |
|
---|
28 | ### indentString(string, [count], [options])
|
---|
29 |
|
---|
30 | #### string
|
---|
31 |
|
---|
32 | Type: `string`
|
---|
33 |
|
---|
34 | The string to indent.
|
---|
35 |
|
---|
36 | #### count
|
---|
37 |
|
---|
38 | Type: `number`<br>
|
---|
39 | Default: `1`
|
---|
40 |
|
---|
41 | How many times you want `options.indent` repeated.
|
---|
42 |
|
---|
43 | #### options
|
---|
44 |
|
---|
45 | Type: `object`
|
---|
46 |
|
---|
47 | ##### indent
|
---|
48 |
|
---|
49 | Type: `string`<br>
|
---|
50 | Default: `' '`
|
---|
51 |
|
---|
52 | The string to use for the indent.
|
---|
53 |
|
---|
54 | ##### includeEmptyLines
|
---|
55 |
|
---|
56 | Type: `boolean`<br>
|
---|
57 | Default: `false`
|
---|
58 |
|
---|
59 | Also indent empty lines.
|
---|
60 |
|
---|
61 |
|
---|
62 | ## Related
|
---|
63 |
|
---|
64 | - [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - CLI for this module
|
---|
65 | - [strip-indent](https://github.com/sindresorhus/strip-indent) - Strip leading whitespace from every line in a string
|
---|
66 |
|
---|
67 |
|
---|
68 | ## License
|
---|
69 |
|
---|
70 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.