plexis-js / plexis

Lo-fi, powerful, community-driven string manipulation library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: `withoutIndent / removeIndent / dedent`

vorillaz opened this issue · comments

Remove leading whitespace from each line in a string

Example usage

import withoutIndent from '@plexis/without-indent';

withoutIndent('Hello world');
// => 'Hello world'

withoutIndent('\nHello world')
// =>
//'
// Hello world'

withoutIndent('\t\t\t\tHello world')
// => 'Hello world'

withoutIndent('\t\t\t\tHello \nworld')
// => '
//				Hello 
// world'


withoutIndent('\t\t\t\tHello\tdear \nworld')
// => '				Hello	dear 
// world'

Aliases

import withoutIndent from '@plexis/without-indent';
import {withoutIndent, removeIndent, dedent} from 'plexis';

I'd like to take this one on!

@adriaanvermeire Sure thing, go for it!

Should this package remove all leading whitespaces from the string. Or all leading whitespaces for every line in the string?
withoutIndent('\t\tHello\n\tWorld') // returns 'Hello\n\tWorld
as opposed to
withoutIndent('\t\tHello\n\tWorld') // returns 'Hello\nWorld