2016-10-10 03:43:44 +02:00
|
|
|
# indent-string [![Build Status](https://travis-ci.org/sindresorhus/indent-string.svg?branch=master)](https://travis-ci.org/sindresorhus/indent-string)
|
|
|
|
|
|
|
|
> Indent each line in a string
|
|
|
|
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
```
|
|
|
|
$ npm install --save indent-string
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
2017-05-27 17:36:13 +02:00
|
|
|
const indentString = require('indent-string');
|
2016-10-10 03:43:44 +02:00
|
|
|
|
2017-05-27 17:36:13 +02:00
|
|
|
indentString('Unicorns\nRainbows', 4);
|
|
|
|
//=> ' Unicorns'
|
|
|
|
//=> ' Rainbows'
|
|
|
|
|
|
|
|
indentString('Unicorns\nRainbows', 4, '♥');
|
|
|
|
//=> '♥♥♥♥Unicorns'
|
|
|
|
//=> '♥♥♥♥Rainbows'
|
2016-10-10 03:43:44 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
2017-05-27 17:36:13 +02:00
|
|
|
### indentString(input, [count], [indent])
|
2016-10-10 03:43:44 +02:00
|
|
|
|
2017-05-27 17:36:13 +02:00
|
|
|
#### input
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
Type: `string`
|
|
|
|
|
2017-05-27 17:36:13 +02:00
|
|
|
String you want to indent.
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
#### count
|
|
|
|
|
2017-05-27 17:36:13 +02:00
|
|
|
Type: `number`<br>
|
2016-10-10 03:43:44 +02:00
|
|
|
Default: `1`
|
|
|
|
|
|
|
|
How many times you want `indent` repeated.
|
|
|
|
|
2017-05-27 17:36:13 +02:00
|
|
|
#### indent
|
|
|
|
|
|
|
|
Type: `string`<br>
|
|
|
|
Default: `' '`
|
|
|
|
|
|
|
|
String to use for the indent.
|
|
|
|
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
## Related
|
|
|
|
|
|
|
|
- [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - CLI for this module
|
|
|
|
- [strip-indent](https://github.com/sindresorhus/strip-indent) - Strip leading whitespace from every line in a string
|
|
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
2017-05-27 17:36:13 +02:00
|
|
|
MIT © [Sindre Sorhus](https://sindresorhus.com)
|