8d8b117cfc5209abb9e4bf5fa6ca9be535125dfa52a39060e1de0dcc625495581c25131602e21644df8f1a3a9c527e2fe75d47a343245f25091877c6620456 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # indent-string [![Build Status](https://travis-ci.org/sindresorhus/indent-string.svg?branch=master)](https://travis-ci.org/sindresorhus/indent-string)
  2. > Indent each line in a string
  3. ## Install
  4. ```
  5. $ npm install indent-string
  6. ```
  7. ## Usage
  8. ```js
  9. const indentString = require('indent-string');
  10. indentString('Unicorns\nRainbows', 4);
  11. //=> ' Unicorns\n Rainbows'
  12. indentString('Unicorns\nRainbows', 4, {indent: '♥'});
  13. //=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
  14. ```
  15. ## API
  16. ### indentString(string, [count], [options])
  17. #### string
  18. Type: `string`
  19. The string to indent.
  20. #### count
  21. Type: `number`<br>
  22. Default: `1`
  23. How many times you want `options.indent` repeated.
  24. #### options
  25. Type: `object`
  26. ##### indent
  27. Type: `string`<br>
  28. Default: `' '`
  29. The string to use for the indent.
  30. ##### includeEmptyLines
  31. Type: `boolean`<br>
  32. Default: `false`
  33. Also indent empty lines.
  34. ## Related
  35. - [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - CLI for this module
  36. - [strip-indent](https://github.com/sindresorhus/strip-indent) - Strip leading whitespace from every line in a string
  37. ## License
  38. MIT © [Sindre Sorhus](https://sindresorhus.com)