Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/strip-indent
Strip leading whitespace from each line in a string
https://github.com/sindresorhus/strip-indent
Last synced: 7 days ago
JSON representation
Strip leading whitespace from each line in a string
- Host: GitHub
- URL: https://github.com/sindresorhus/strip-indent
- Owner: sindresorhus
- License: mit
- Created: 2014-03-29T14:15:08.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2021-09-17T11:46:19.000Z (over 3 years ago)
- Last Synced: 2024-10-29T12:58:11.680Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 135
- Watchers: 8
- Forks: 18
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
- awesome-nodejs-cn - strip-indent - 从字符串的每一行中除去前导空格. (包 / 文本)
- awesome-nodejs - strip-indent - Strip leading whitespace from every line in a string. (Repository / Text/String)
- awesome-nodejs - strip-indent - Strip leading whitespace from every line in a string. (Packages / Text)
- awesome-nodejs - strip-indent - Strip leading whitespace from each line in a string - ★ 77 (Text)
- awesome-node - strip-indent - Strip leading whitespace from every line in a string. (Packages / Text)
- awesome-nodejs-cn - strip-indent - 从字符串的每一行中除去前导空格. (目录 / 文本处理)
- awesome-nodejs-cn - strip-indent - **star:136** 从字符串中的每一行中去除前导空格 (包 / 文本)
README
# strip-indent
> Strip leading whitespace from each line in a string
The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.
Useful for removing redundant indentation.
## Install
```
$ npm install strip-indent
```## Usage
```js
import stripIndent from 'strip-indent';const string = '\tunicorn\n\t\tcake';
/*
unicorn
cake
*/stripIndent(string);
/*
unicorn
cake
*/
```## Related
- [strip-indent-cli](https://github.com/sindresorhus/strip-indent-cli) - CLI for this module
- [indent-string](https://github.com/sindresorhus/indent-string) - Indent each 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.