Strip leading whitespace from each line in a string
JavaScript
Switch branches/tags
Clone or download
Latest commit 767c465 Nov 4, 2017
Permalink
Failed to load latest commit information.
.editorconfig Meta tweaks Nov 4, 2017
.gitattributes Meta tweaks Apr 22, 2017
.gitignore Meta tweaks Nov 4, 2017
.npmrc Meta tweaks Nov 4, 2017
.travis.yml Meta tweaks Nov 4, 2017
index.js Use min-indent (#4) Nov 4, 2017
license Meta tweaks Nov 4, 2017
package.json Meta tweaks Nov 4, 2017
readme.md Meta tweaks Nov 4, 2017
test.js Meta tweaks Apr 22, 2017

readme.md

strip-indent Build Status

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

const stripIndent = require('strip-indent');

const str = '\tunicorn\n\t\tcake';
/*
	unicorn
		cake
*/

stripIndent(str);
/*
unicorn
	cake
*/

Related

License

MIT © Sindre Sorhus