Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/indent-string
Indent each line in a string
https://github.com/sindresorhus/indent-string
Last synced: 4 days ago
JSON representation
Indent each line in a string
- Host: GitHub
- URL: https://github.com/sindresorhus/indent-string
- Owner: sindresorhus
- License: mit
- Created: 2014-06-06T20:16:03.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2022-06-05T07:44:39.000Z (over 2 years ago)
- Last Synced: 2024-12-01T00:34:22.478Z (11 days ago)
- Language: JavaScript
- Size: 32.2 KB
- Stars: 112
- Watchers: 7
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
- awesome-nodejs-cn - indent-string - 缩进字符串中的每一行. (包 / 文本)
- awesome-nodejs - indent-string - Indent each line in a string. (Repository / Text/String)
- awesome-nodejs-cn - indent-string - **star:112** 缩进字符串中的每一行 (包 / 文本)
- awesome-github-star - indent-string
- awesome-nodejs - indent-string - Indent each line in a string. (Packages / Text)
- awesome-nodejs - indent-string - Indent each line in a string - ★ 57 (Text)
- awesome-cli - indent-string - Indent each line in a string. (Helpful)
- awesome-node - indent-string - Indent each line in a string. (Packages / Text)
- awesome-nodejs-cn - indent-string - 缩进字符串中的每一行. (目录 / 文本处理)
README
# indent-string
> Indent each line in a string
## Install
```
$ npm install indent-string
```## Usage
```js
import indentString from 'indent-string';indentString('Unicorns\nRainbows', 4);
//=> ' Unicorns\n Rainbows'indentString('Unicorns\nRainbows', 4, {indent: '♥'});
//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
```## API
### indentString(string, count?, options?)
#### string
Type: `string`
The string to indent.
#### count
Type: `number`\
Default: `1`How many times you want `options.indent` repeated.
#### options
Type: `object`
##### indent
Type: `string`\
Default: `' '`The string to use for the indent.
##### includeEmptyLines
Type: `boolean`\
Default: `false`Also indent empty lines.
## 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
- [redent](https://github.com/sindresorhus/redent) - Strip redundant indentation and indent the string---
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.