selective-whitespace
Condense all whitespace in a string, with options to preserve specific whitespace characters.
Install
$ npm install --save selective-whitespace
Usage
var selectiveWhitespace = require('selective-whitespace');
selectiveWhitespace(' FOO BAR BAZ ');
selectiveWhitespace('FOO\n BAR\n BAZ\n ', { keep: '\n' });
selectiveWhitespace('\tFOO \tBAR \tBAZ', { keep: '\t' });
selectiveWhitespace('\n\tFOO \n\tBAR \n\tBAZ', { keep: '\t,\n' });
selectiveWhitespace('\t\nFOO \t\nBAR \t\nBAZ', { stripAll:true });
API
selectiveWhitespace(str, [options]);
str
The string you want to condense
options
Type: object
- keep
- Values to preserve. Comma or pipe-delimited list.
- Type:
string
- options:
\n\t\r
- stripAll
License
MIT © Michael Wuergler